-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SENDING_RESPONSE_CLIENT_CLOSED state into HttpPipelineHandler FSM #214
Add SENDING_RESPONSE_CLIENT_CLOSED state into HttpPipelineHandler FSM #214
Conversation
b1e8a97
to
d270081
Compare
@@ -203,5 +203,11 @@ public int hashCode() { | |||
public StateMachine<S> build() { | |||
return new StateMachine<>(initialState, stateEventHandlers, inappropriateEventHandler, stateChangeListener); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method used? It doesn't show up if I look for 'debugTransitions' in this PR. Maybe we want to include this idea of (conditionally) logging state transitions instead of removing it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey David.
I would just leave this in. When debugging unit tests or e2e tests I can just add a .debugTransitions
call to the state machine builder, and remove when ready.
Of course it could be integrated more nicely. 🤔
.transition(SENDING_RESPONSE_CLIENT_CLOSED, ResponseSentEvent.class, event -> onResponseSentAfterClientClosed(event.ctx)) | ||
.transition(SENDING_RESPONSE_CLIENT_CLOSED, ResponseWriteErrorEvent.class, event -> onResponseWriteError(event.ctx, event.cause)) | ||
.transition(SENDING_RESPONSE_CLIENT_CLOSED, ChannelInactiveEvent.class, event -> { | ||
LOGGER.warn(warningMessage("Weird. This event/state was not supposed to happen.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we handle this in the 'onInappropriateEvent' case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed we can. I will modify the code accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a change.
verify(statsCollector).onTerminate(request.id()); | ||
assertThat(adapter.state(), is(TERMINATED)); | ||
} | ||
// @Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do something with this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have been looking at old diff?
… FSM (ExpediaGroup#214) Handles TCP connection closures from connected clients more predictably. (cherry picked from commit 16d01cf)
Problem Description
Improve HttpPipelineHandler FSM to make it more predictable especially for some end to end tests.
There is a following scenario which sometimes causes intermittent e2e failures:
onNext
event.channelInactive
event prior to response observableonCompleted
event.Mostly this affects only those e2e tests whose assertions are based on observing changes in metrics. This has never caused any concern in production environments, where the incoming TCP connections tend to be pooled anyway.
The Fix
To remedy this situation, I have added a new SENDING_RESPON/SE_CLIENT_CLOSED state which allows HttpPipelineHandler to wait for
onComplete
from the response observable. IfonComplete
is seen the response is treated as success. Otherwise it is treated as failure.