Repository navigation
Conversation
The timeout is the HttpClient's, which ends with the response headers (the body is read after, with ResponseHeadersRead). A node that sent the headers and then stalled (a half-open connection, a node that is paused) kept the call waiting for ever: no failure, no node marked dead, nothing to fail over from. The body is now read with a token that is cancelled when what is left of the request timeout has gone, so such a node fails the call as one that does not answer does. A synchronous read has no token to cancel. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
API changes in this pull request: suggested version change NoneCompared with the base branch
Since the last release: Major, 42 breaking changes; for information, it does not fail this checkElastic.Transport.dll: Major, 28 breaking changes
Elastic.Transport.VirtualizedCluster.dll: Major, 14 breaking changes
Public API files✅ The committed API files match the build (7 files). |
This branch has not been deployed
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.
Stacked on #310 (it uses that PR's handling of a failure while the body is read); retarget to
mainonce #310 is merged.Why
Found by the soak (#308): after the test killed a node, three calls were still waiting minutes later, in
ContentLengthReadStream.ReadAsyncunderJsonResponseBuilder, far past the 60 s defaultRequestTimeout.RequestTimeoutis theHttpClient'sTimeout, and withHttpCompletionOption.ResponseHeadersReadthat ends when the headers are in. The body is read afterwards, by the response builder, with only the caller's token. So a node that sends the headers and then stalls (a half-open connection, a paused or overloaded node, a partition) keeps the call waiting for ever: no failure, no node marked dead, nothing to fail over from. Reproduced with a raw TCP node that sends the headers and 100 of 2000 bytes and then does nothing,RequestTimeout500 ms: the call was still waiting after 8 s, while a node that never answers at all fails at 514 ms.What
The body is read with a token linked to the caller's and cancelled after what is left of the request timeout (the timeout minus the time the headers took). A stalled body now fails the call with the cancellation, like one that does not answer: the node goes out of rotation and the request fails over (within
MaxRetryTimeout, which defaults to the request timeout, so give the request more than one timeout's worth to fail over). Not for the response types that hand the stream to the caller (StreamResponse, pipes): they read it after the call, as before. A synchronous read has no token to cancel and is unchanged.Cost: one linked token source and timer per async request: +168 B/request (+1.9%) and −0.8% throughput on a local loopback server (126.9k → 125.9k req/s, 8,921 → 9,089 B/req, two runs each, 64 workers).
Tests
BodyReadFailureTests: a node that stalls half way through the body returns the failure within the timeout (it waited 10 s and gave up before), and the request fails over to a healthy node with the stalled one out of rotation. Both fail without the timer on the read. Transport, Properties, Integration and Pipes suites pass on net10.0.🤖 Generated with Claude Code