-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Fix Netty4ChunkedContinuationsIT#testClientCancellation #110118
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
Merged
nicktindall
merged 8 commits into
elastic:main
from
nicktindall:fix/109866_investigate_chunked_continuations_test
Jun 27, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8509f44
Add leak tracking and re-enable chunked continuation test
nicktindall b0a9cb6
Fix suspected issue
nicktindall d4330f9
Merge branch 'main' into fix/109866_investigate_chunked_continuations…
nicktindall 818b074
Merge remote-tracking branch 'origin/main' into fix/109866_investigat…
nicktindall 92388e2
Revert "Fix suspected issue"
nicktindall 30c2001
Fix Netty4ChunkedContinuationsIT#testClientCancellation
nicktindall 13f4496
Merge remote-tracking branch 'origin/main' into fix/109866_investigat…
nicktindall 8561e53
Unmute test again
nicktindall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
After looking at a failed build scan with the logging turned on, it became apparent that the unbalanced sequence of events went like (most recent first):
Netty4ChunkedContinuationsIT:641Netty4ChunkedContinuationsIT:324Netty4ChunkedContinuationsIT:646Netty4ChunkedContinuationsIT:637Netty4ChunkedContinuationsIT.java:322Which suggests to me the following sequence of events:
RestChannelConsumer.acceptis called (andmustIncRefis called)TransportInfiniteContinuationsAction.doExecuteis called and schedules the return of the chunked responseRestActionListener#onResponsefails in the call to#ensureOpen()and ends up callingRestActionListener#onFailureinstead ofRestActionListener#processResponseso thedecRefon line 655 is never called, and we have our inbalance.Options for fixing
If we move the
mustIncRefsuch that it only occurs when we receive theInfiniteContinuationsPlugin.Responsefrom the action (as above), the test shouldn't be susceptible to such a failure, but it does indicate that theResponseobject can be created but never closed. I'm not sure if this is an actual bug.Responsetype parameter doesn't have any type constraints inRestActionListenerso it's not necessarilyReleasable. I'm not clear on what the contract is here and whetherRestActionListenerhas a responsibility to try and close theResponsewhen it fails due to#ensureOpen()throwing.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 the new positioning of
mustIncRefis OK, because instead of"if we accepted the request" -> "then we close the chunked response"
we now assert
"if we created the chunked response" -> "then we close the chunked response"
But I may have missed something.
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 other plugins (
YieldsContinuationsPluginat least) seem to have the same issue, but I guess it doesn't trigger because we wait for the request to complete when calling those.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.
Good job on tracking this down. I can confirm the test can fail with following diff
I think this is the right fix we are doing the same thing in other
RestActionListenerimplementation. 👍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.
Good catch, the analysis looks right to me. However I would still prefer that we didn't just leak the response listener in this case, that's not how production code should behave, and we should be able to assert that it's always completed. I opened #110309 with an alternative fix which I would prefer.