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
Respect promises on pipelined responses #23317
Conversation
a4a101e
to
7ebdd4d
Compare
When pipelined responses are sent to the pipeline handler for writing, they are not necessarily written immediately. They must be held in a priority queue until all responses preceding the given response are written. This means that when write is invoked on the handler, the promise that is attached to the write invocation will not necessarily be the promise associated with the responses that are written while the queue is drained. To address this, the promise associated with a pipelined response must be held with the response and then used when the channel context is actually written to. This was introduced when ensuring that the releasing promise is always chained through on write calls lest the releasing promise never be invoked. This leads to many failing test cases, so no new test cases are needed here.
7ebdd4d
to
1430c5f
Compare
This commit sets the intial size of the pipeline handler queue small to prevent waste if pipelined requests are never sent. Since the queue will grow quickly if pipeline requests are indeed set, this should not be problematic.
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.
LGTM, though I don't feel comfortable I can oversee unexpected side effects (thanks for slowly making me learn netty). Maybe @spinscale can look at it as well?
@@ -33,7 +33,8 @@ | |||
*/ | |||
public class HttpPipeliningHandler extends ChannelDuplexHandler { | |||
|
|||
private static final int INITIAL_EVENTS_HELD = 8; |
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 related to this change? if not , should we move it to separate PR?
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.
Sure, I'll move it to a separate change.
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 pushed 70d57b7.
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 opened #23335.
* responses that precede it in the pipeline are written first. Note that the promise from the method invocation is | ||
* not ignored, it will already be attached to an existing response and consumed when that response is drained. | ||
*/ | ||
ctx.write(response.response(), response.promise()); |
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 assert at the beginning of this if clause that the promise in the HttpPipelinedResponse is that one we got as a parameter?
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 pushed 072c81d.
looks good to me |
This reverts commit 30cdefc.
* master: Align REST specs for HEAD requests Remove unnecessary result sorting in SearchPhaseController (elastic#23321) Fix SamplerAggregatorTests to have stable and predictable docIds Tests: Ensure multi node integ tests wait on first node
When pipelined responses are sent to the pipeline handler for writing, they are not necessarily written immediately. They must be held in a priority queue until all responses preceding the given response are written. This means that when write is invoked on the handler, the promise that is attached to the write invocation will not necessarily be the promise associated with the responses that are written while the queue is drained. To address this, the promise associated with a pipelined response must be held with the response and then used when the channel context is actually written to. This was introduced when ensuring that the releasing promise is always chained through on write calls lest the releasing promise never be invoked. This leads to many failing test cases, so no new test cases are needed here. Relates #23317
When pipelined responses are sent to the pipeline handler for writing, they are not necessarily written immediately. They must be held in a priority queue until all responses preceding the given response are written. This means that when write is invoked on the handler, the promise that is attached to the write invocation will not necessarily be the promise associated with the responses that are written while the queue is drained. To address this, the promise associated with a pipelined response must be held with the response and then used when the channel context is actually written to. This was introduced when ensuring that the releasing promise is always chained through on write calls lest the releasing promise never be invoked. This leads to many failing test cases, so no new test cases are needed here. Relates #23317
When pipelined responses are sent to the pipeline handler for writing, they are not necessarily written immediately. They must be held in a priority queue until all responses preceding the given response are written. This means that when write is invoked on the handler, the promise that is attached to the write invocation will not necessarily be the promise associated with the responses that are written while the queue is drained. To address this, the promise associated with a pipelined response must be held with the response and then used when the channel context is actually written to. This was introduced when ensuring that the releasing promise is always chained through on write calls lest the releasing promise never be invoked. This leads to many failing test cases, so no new test cases are needed here. Relates #23317
Thanks for reviewing @bleskes and @spinscale. |
When pipelined responses are sent to the pipeline handler for writing, they are not necessarily written immediately. They must be held in a priority queue until all responses preceding the given response are written. This means that when write is invoked on the handler, the promise that is attached to the write invocation will not necessarily be the promise associated with the responses that are written while the queue is drained. To address this, the promise associated with a pipelined response must be held with the response and then used when the channel context is actually written to. This was introduced when ensuring that the releasing promise is always chained through on write calls lest the releasing promise never be invoked. This leads to many failing test cases, so no new test cases are needed here.
Relates #23310, closes #23322