-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[Test] Wait for cancellation before assertions #134532
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
elasticsearchmachine
merged 9 commits into
elastic:main
from
ywangd:es-134277-fix-again
Sep 17, 2025
+13
−4
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2984af4
[Test] Wait for cancellation before assertions
ywangd 0bdc5a7
Merge branch 'main' into es-134277-fix-again
elasticmachine 61edb11
Merge branch 'main' into es-134277-fix-again
ywangd bb782eb
Merge remote-tracking branch 'origin/main' into es-134277-fix-again
ywangd eedd108
unmute
ywangd e407c3e
Merge branch 'main' into es-134277-fix-again
ywangd 453b98f
Merge branch 'main' into es-134277-fix-again
ywangd d8dece3
Merge branch 'main' into es-134277-fix-again
ywangd 54970e9
Merge branch 'main' into es-134277-fix-again
ywangd 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
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.
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 turns out we still need the latch. It was actually part of the original issue, i.e. the cancellation can comes in after all node responses are collected and right before the final response is sent. In this case, the final response is short circuited to be an exception while the cancellation listener is still doing work.
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.
Hmm ok I think I see, so you mean the final response can be sent in between these two lines:
elasticsearch/server/src/main/java/org/elasticsearch/action/support/CancellableFanOut.java
Lines 78 to 80 in a59c182
On reflection this seems kinda surprising if not an outright bug: we generally prefer to delay sending the response until everything is released.
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.
Not the above lines. The final response (cancellation) can be sent at this line
elasticsearch/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java
Line 179 in 6884dbb
before the node responses are released by this line
elasticsearch/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java
Line 120 in 6884dbb
A potential alternative fix is to add a similar synchronized block to drain node responses right before the first line linked above. What do you think?
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.
Ah yeah sorry this is all quite a tangle. I don't think it'll work to drain responses in
onCompletion
- we could already have drained them in the listener withinaddReleaseOnCancellationListener
but still not quite released them yet.On reflection it looks like there's other ways we can complete the final listener before releasing all the node-level responses, e.g. here:
elasticsearch/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java
Lines 171 to 173 in 74fd66c
Let's leave this alone then; I appreciate the comment in the test calling out that this is slightly odd.