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
Fix flaky testUploadWithPendingReadConcurrentServerCloseClosesStream()
#11693
Fix flaky testUploadWithPendingReadConcurrentServerCloseClosesStream()
#11693
Conversation
…Stream() Signed-off-by: Ludovic Orban <lorban@bitronix.be>
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> |
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 relevant for the fix?
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.
It's not, but it avoids a warning from the JVM when running on JDK 22. Do you want me to move that change to another PR?
assertTrue(Content.Chunk.isFailure(lastChunk.get(), true)); | ||
assertInstanceOf(IOException.class, lastChunk.get().getFailure()); | ||
// Since the connector was stopped, there is no guarantee that | ||
// the pending demand got serviced with an error chunk. |
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.
It's not clear... you mean that the demand is not invoked at all, or that it is invoked, but not with an error chunk?
I think serverDemandLatch
must be counted down, i.e. the demand must be invoked with an error chunk.
If the problem is that the connector is stopped when inside the demand callback with a normal chunk, then either we should convert the implementation into a loop (so we read the error chunk), or setting the demand when there was a failure should invoke immediately the demand again.
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.
The problem lies in HTTP2ServerConnection.onStreamFailure()
which does the following:
Runnable task = channel.onFailure(failure, callback);
if (task != null)
{
// We must dispatch to another thread because the task
// may call application code that performs blocking I/O.
offerTask(task, true); // true means call strategy.dispatch()
}
Since it is the task
returned by channel.onFailure()
that eventually services the demand, there is no guarantee that it's going to be executed as there is a race condition between the strategy's thread executing the queued task and the strategy being stopped because it is part of the connector being stopped.
…0.x/11692-fix-flaky-testUploadWithPendingReadConcurrentServerCloseClosesStream
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@sbordet I've submitted an alternate fix for the flakyness of that test that requires a delicate change in |
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Fixes #11692