-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
[Profiling] Ensure responses are only sent once #93692
Merged
danielmitterdorfer
merged 2 commits into
elastic:main
from
danielmitterdorfer:profiling-duplicate-resp
Feb 10, 2023
Merged
[Profiling] Ensure responses are only sent once #93692
danielmitterdorfer
merged 2 commits into
elastic:main
from
danielmitterdorfer:profiling-duplicate-resp
Feb 10, 2023
Conversation
This file contains 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
For performance reasons the profiling plugin issues multiple requests concurrently. It uses internal handler classes to keep track of state. When all responses of dependent requests have arrived, it assembles the response and sends it to the client. The final state handler used two atomic counters to track outstanding requests. This has led to a race condition: When the two code paths finished at the same time, the plugin attempted to send the response twice. With this commit we simplify state handling by only using a single atomic counter for both code paths. We decrement the counter only in a single place and will send the response iff all dependent requests have finished. Closes elastic#93691
danielmitterdorfer
added
>bug
:Search/Search
Search-related issues that do not fall into other categories
v8.7.0
v8.7.1
v8.8.0
labels
Feb 10, 2023
Pinging @elastic/es-search (Team:Search) |
Hi @danielmitterdorfer, I've created a changelog YAML for you. |
danielmitterdorfer
added
the
auto-backport-and-merge
Automatically create backport pull requests and merge when ready
label
Feb 10, 2023
benwtrent
approved these changes
Feb 10, 2023
mayFinish(); | ||
} | ||
|
||
public void mayFinish() { | ||
if (expectedStackFrameSlices.get() == 0 && expectedExecutableSlices.get() == 0) { | ||
if (expectedSlices.decrementAndGet() == 0) { |
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.
👍
Thanks for the quick review @benwtrent! |
danielmitterdorfer
added a commit
to danielmitterdorfer/elasticsearch
that referenced
this pull request
Feb 10, 2023
For performance reasons the profiling plugin issues multiple requests concurrently. It uses internal handler classes to keep track of state. When all responses of dependent requests have arrived, it assembles the response and sends it to the client. The final state handler used two atomic counters to track outstanding requests. This has led to a race condition: When the two code paths finished at the same time, the plugin attempted to send the response twice. With this commit we simplify state handling by only using a single atomic counter for both code paths. We decrement the counter only in a single place and will send the response iff all dependent requests have finished. Closes elastic#93691
💚 Backport successful
|
elasticsearchmachine
pushed a commit
that referenced
this pull request
Feb 10, 2023
For performance reasons the profiling plugin issues multiple requests concurrently. It uses internal handler classes to keep track of state. When all responses of dependent requests have arrived, it assembles the response and sends it to the client. The final state handler used two atomic counters to track outstanding requests. This has led to a race condition: When the two code paths finished at the same time, the plugin attempted to send the response twice. With this commit we simplify state handling by only using a single atomic counter for both code paths. We decrement the counter only in a single place and will send the response iff all dependent requests have finished. Closes #93691
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
auto-backport-and-merge
Automatically create backport pull requests and merge when ready
>bug
:Search/Search
Search-related issues that do not fall into other categories
Team:Search
Meta label for search team
v8.7.0
v8.7.1
v8.8.0
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.
For performance reasons the profiling plugin issues multiple requests concurrently. It uses internal handler classes to keep track of state. When all responses of dependent requests have arrived, it assembles the response and sends it to the client. The final state handler used two atomic counters to track outstanding requests. This has led to a race condition: When the two code paths finished at the same time, the plugin attempted to send the response twice.
With this commit we simplify state handling by only using a single atomic counter for both code paths. We decrement the counter only in a single place and will send the response iff all dependent requests have finished.
Closes #93691