Repository navigation
Rest5Client: do not retry requests with a non-repeatable entity - #1371
Merged
l-trotta merged 1 commit intoNov 6, 2026
Merged
Conversation
|
💚 CLA has been signed |
Contributor
|
thanks @hidingmyname , this looks good, sorry for the broken tests, happens in prerelease days :) but it runs fine locally. could you just sign the CLA? |
A non-repeatable entity, such as an InputStreamEntity, is consumed by the first attempt. Retrying it on the next node sends an empty body when the length is unknown, so the request can appear to succeed, and hangs when a content length is set. Stop at the first failure for these requests, in the synchronous and asynchronous paths. Fixes elastic#1356
hidingmyname
force-pushed
the
rest5-no-retry-non-repeatable-entity
branch
from
November 5, 2026 17:17
3f086c5 to
0b5b690
Compare
Contributor
Author
|
Thanks! The CLA is signed and the check passes now. |
l-trotta
approved these changes
Nov 6, 2026
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.
Fixes #1356
What changed
Rest5Clientretried failed requests on the next node without checking whether the request entity could be sent again. A non-repeatable entity, such as anInputStreamEntity, is consumed by the first attempt, so a retry either sends an empty body and can report success (unknown length), or sends aContent-Lengthwith no body and waits for a response (known length).Requests with a non-repeatable entity now stop at the first failure, on all four retry paths: status codes 502/503/504 and retryable exceptions, in both
performRequestandperformRequestAsync. The caller gets the originalResponseExceptionor exception. Requests with no entity or a repeatable entity are retried as before, which includesElasticsearchClientrequest bodies (MultiBufferEntityis repeatable).Trade-off
These requests also lose failover when the first attempt failed before the stream was read, for example on connection refused, which works today. The client can't tell in general how much of the stream was consumed, so it doesn't retry them at all. elasticsearch-js made the same choice in #1143, setting
maxRetriesto 0 for stream bodies.Tests
The new
RestClientStreamBodyRetryTestshas 6 tests:IOException.The known-length hang has no test, because on unpatched code it would block until the test run is killed.
Results on JDK 17.0.21 (Temurin) with the Gradle wrapper (8.13):
Rest5Clientchange: 118 tests, 5 failed, 1 skipped. The failures are the 5 new no-retry tests; the control passes.:rest5-client:check, which includescheckstyleMainandcheckstyleTest, passes with 118 tests, 0 failed, 1 skipped.I didn't run this against a real Elasticsearch node, and I ran the checks for
rest5-clientonly. On currentmain,:java-clientdoesn't resolve here becauseorg.elasticsearch.client:elasticsearch-rest-client:9.6.0isn't found, so./gradlew checkcan't complete locally. This PR doesn't touchjava-client.