sync api: cancel queries when the calling thread is interrupted by always using the underlying HTTP client async api#1196
Closed
lovasoa wants to merge 2 commits intoelastic:mainfrom
Closed
Conversation
|
💚 CLA has been signed |
lovasoa
added a commit
to lovasoa/elasticsearch-java
that referenced
this pull request
Apr 1, 2026
When the thread is interrupted, cancel the underlying http request instead of letting it run to completion. This avoids runaway tasks running on the ES cluster while their client has been interrupted and will never read the results. fixes elastic#1195 This is an alternative to elastic#1196 . That pr fixed the issue with any http client, including those outside of our control that have the same issue. This PR focuses on our own rest client. The bug will still be present when the library is used with other http clients that do not cancel requests on interruption.
lovasoa
added a commit
to lovasoa/elasticsearch-java
that referenced
this pull request
Apr 1, 2026
When the thread is interrupted, cancel the underlying http request instead of letting it run to completion. This avoids runaway tasks running on the ES cluster while their client has been interrupted and will never read the results. fixes elastic#1195 This is an alternative to elastic#1196 . That pr fixed the issue with any http client, including those outside of our control that have the same issue. This PR focuses on our own rest client. The bug will still be present when the library is used with other http clients that do not cancel requests on interruption.
l-trotta
added a commit
that referenced
this pull request
Apr 8, 2026
* rest5client: cancel http request on interruption When the thread is interrupted, cancel the underlying http request instead of letting it run to completion. This avoids runaway tasks running on the ES cluster while their client has been interrupted and will never read the results. fixes #1195 This is an alternative to #1196 . That pr fixed the issue with any http client, including those outside of our control that have the same issue. This PR focuses on our own rest client. The bug will still be present when the library is used with other http clients that do not cancel requests on interruption. * client.execute() stays inside the try block addresses #1197 (comment) --------- Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com>
Contributor
|
closing this in favor of #1197 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pr changes ElasticsearchTransportBase.performRequest to use
httpClient.performRequestAsyncinstead ofhttpClient.performRequest. This allows it to always ensure the request is cancelled on interruption.fixes #1195