Cancel stream on abort or timeout to prevent CRT HTTP client connection pool exhaustion#6919
Open
joviegas wants to merge 12 commits into
Open
Cancel stream on abort or timeout to prevent CRT HTTP client connection pool exhaustion#6919joviegas wants to merge 12 commits into
joviegas wants to merge 12 commits into
Conversation
…nection from pool
55f6b1d to
af112fb
Compare
zoewangg
reviewed
Apr 29, 2026
494bbca to
df131c1
Compare
zoewangg
reviewed
Apr 30, 2026
| long finalAcquireStartTime = acquireStartTime; | ||
|
|
||
| streamFuture.whenComplete((streamBase, throwable) -> { | ||
| if (shouldPublishMetrics) { |
Contributor
There was a problem hiding this comment.
It seems like we can invoke onAcquireStream here?
|
|
||
| try (SdkHttpClient client = AwsCrtHttpClient.builder().maxConcurrency(3).build()) { | ||
| stubUnresponsiveServer(); | ||
| executeAndAbort(client, uri, 3); |
Contributor
There was a problem hiding this comment.
Just curious, why do we need to send 3 requests?
Contributor
Author
There was a problem hiding this comment.
We use 3 to match maxConcurrency(3) and verify all 3 dead connections are evicted and the pool can accept 3 new requests.
5efcffe to
603b69d
Compare
603b69d to
6a13a35
Compare
…treamFuture.whenComplete in both sync and async executors, removing the redundant thenAccept callback and Also fix a connection pool leak race where an abort/timeout before stream acquisition left the late-acquired stream unclosed; closeConnection() now records intent so onAcquireStream() cancels and closes it
469b8e8 to
484e62c
Compare
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.
Motivation and Context
When API call timeout fires, the SDK does not abort the in-flight CRT HTTP request, causing connections to remain permanently leased and eventually exhausting the connection pool.
cancel()support in aws-crt-java#979Modifications
CrtRequestExecutor(sync) andCrtAsyncRequestExecutor(async), register arequestFuture.whenCompletehook that callsHttpStreamBase.cancel()when the futurecompletes exceptionally.
Testing
Screenshots (if appropriate)
Types of changes
License