-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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 plugin may attempt to send response twice #93691
Labels
>bug
:Search/Search
Search-related issues that do not fall into other categories
Team:Search
Meta label for search team
v8.7.0
Comments
Pinging @elastic/es-search (Team:Search) |
danielmitterdorfer
added a commit
to danielmitterdorfer/elasticsearch
that referenced
this issue
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
danielmitterdorfer
added a commit
to danielmitterdorfer/elasticsearch
that referenced
this issue
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
danielmitterdorfer
added a commit
that referenced
this issue
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
danielmitterdorfer
added a commit
to danielmitterdorfer/elasticsearch
that referenced
this issue
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
elasticsearchmachine
pushed a commit
that referenced
this issue
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
salvatore-campagna
pushed a commit
to salvatore-campagna/elasticsearch
that referenced
this issue
Feb 16, 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
saarikabhasi
pushed a commit
to saarikabhasi/elasticsearch
that referenced
this issue
Apr 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
>bug
:Search/Search
Search-related issues that do not fall into other categories
Team:Search
Meta label for search team
v8.7.0
Elasticsearch Version
8.7.0-SNAPSHOT
Installed Plugins
No response
Java Version
bundled
OS Version
N/A
Problem Description
During benchmarking I noticed the following stack trace in the ES logs:
This indicates that we attempt to send the response twice, see:
elasticsearch/server/src/main/java/org/elasticsearch/rest/RestController.java
Lines 759 to 761 in 8ec73d6
and
elasticsearch/server/src/main/java/org/elasticsearch/rest/RestController.java
Lines 770 to 773 in 8ec73d6
This is caused by a race condition in the profiling plugin. It guards with two atomics against duplicate responses but if the method is called after both atomics have just been decremented to zero, we will send the response twice:
elasticsearch/x-pack/plugin/profiler/src/main/java/org/elasticsearch/xpack/profiler/TransportGetProfilingAction.java
Lines 422 to 429 in 8ec73d6
Steps to Reproduce
Issue repeated calls against
/_profiling/stacktrace
. As this is a concurrency issue, it may take a few iterations to manifest.Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: