Repository navigation
HTTPCLIENT-2437: LaxConnPool fails expired lease requests queued behind a live one - #738
Merged
Merged
Conversation
…nd a live one PerRoutePool#servicePendingRequests stops at the first request it cannot serve. When that request has not expired yet, expired requests queued behind it are not failed by closeExpired() or closeIdle() and stay pending until they reach the head of the queue. enumAvailable() now also runs validatePendingRequests(), which checks every pending request, as StrictConnPool already does.
ok2c
approved these changes
Nov 4, 2026
arturobernalg
approved these changes
Nov 4, 2026
Member
|
Cherry-picked to |
Member
|
Thank you @shinseongsu |
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.
Follow-up to #735 for HTTPCLIENT-2437.
LaxConnPoolalready completes the future of an expired request, but only when that request is at the head of the queue.PerRoutePool#servicePendingRequestsstops at the first request it cannot serve, so when the head request has not expired yet, expired requests behind it are not failed bycloseExpired()orcloseIdle().This shows up when lease requests on the same route use different
connectionRequestTimeoutvalues. With a pool of 1, request B (1 minute) and then request C (100 ms) waiting behind a leased connection, C is still pending aftercloseExpired().StrictConnPoolfails C in the same case, asprocessPendingRequests()walks the whole queue.enumAvailable()now also callsvalidatePendingRequests(), which checks every pending request.Is this approach OK with you? I kept the change in
enumAvailable()so that onlycloseExpired()/closeIdle()change and the lease/release path stays as it is. The other option I considered is to letservicePendingRequests()keep scanning past a request it cannot serve and fail the expired ones there, which would also cover release, but it touches the hot path. Happy to change it if you prefer that.Tests: the new
TestPoolPendingRequestExpirycase fails on master forLAXonly and passes with the change. httpcore5 verify: 2011 tests, 0 failures.5.4.x has the same code. I have the same change on a 5.4.x branch, with the test using the real clock as in the #735 cherry-pick; it fails before the change and passes after (httpcore5 verify: 1264 tests). Should I open a separate PR for 5.4.x, or would you prefer to cherry-pick it?