Skip to content

feat(crt): add maxPendingConnectionAcquires - #7522

Open
zoewangg wants to merge 2 commits into
masterfrom
zoewang/crt-max-pending-acquires
Open

zoewangg wants to merge 2 commits into
masterfrom
zoewang/crt-max-pending-acquires

Conversation

@zoewangg

@zoewangg zoewangg commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Not ready to merge. On HTTP/2, this change depends on an upcoming aws-crt-java release that includes awslabs/aws-crt-java#1032, in which the HTTP/2 stream manager honors the pending-acquisition limit.

Motivation and Context

NettyNioAsyncHttpClient.Builder has maxPendingConnectionAcquires, which limits how many requests can wait once all connections (HTTP/1.1) or streams (HTTP/2) are in use. The AWS CRT HTTP clients have no equivalent: waiting requests are unbounded.

Modifications

  • Add maxPendingConnectionAcquires(Integer) to AwsCrtAsyncHttpClient.Builder and AwsCrtHttpClient.Builder, which is consistent the Netty option.
    • The default behavior is unbounded to be backwards compatible. Javadoc is updated to mention to set it to 10,000 to keep the Netty behavior when migrating.
  • A request over the limit fails immediately with the CRT exception. It is not retryable (not wrapped with IOException), matching Netty.

Testing

  • added functional tests and unit tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

AI tools

  • I wrote this pull request description myself, not with an AI tool
  • I have reviewed all changes in this pull request myself, including any generated by AI tools

License

  • I confirm that this pull request can be released under the Apache 2 license

codes.add(2092);
// AWS_ERROR_HTTP_CONNECTION_MANAGER_ACQUISITION_TIMEOUT
codes.add(2093);
// AWS_ERROR_HTTP_CONNECTION_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing 2094 from the retryable codes doesn't change behavior for existing users because it was basically unreachable until now. aws-c-http only raises 2094 when max_pending_connection_acquisitions is set, and the SDK never set it (HttpClientConnectionManagerOptions.withMaxPendingConnectionAcquisitions was never called).

The reason we removed it here is to match netty behavior; we don't retry max pending acquisitions error for netty

@zoewangg
zoewangg force-pushed the zoewang/crt-max-pending-acquires branch 2 times, most recently from 48847cc to 74b91e7 Compare November 18, 2026 17:23
Cap how many requests per endpoint can wait once maxConcurrency is in
use, matching the Netty client option. Unset means unbounded, as
today. HTTP/2 needs an aws-crt release that honors the limit.
The HTTP/2 over-limit rejection (CrtRuntimeException 2096) is surfaced
as is and not retried, like HttpException 2094 on HTTP/1.1.
@zoewangg
zoewangg force-pushed the zoewang/crt-max-pending-acquires branch from 74b91e7 to fa8e431 Compare November 18, 2026 20:49
@zoewangg
zoewangg marked this pull request as ready for review November 19, 2026 17:02
@zoewangg
zoewangg requested a review from a team as a code owner November 19, 2026 17:02
@zoewangg
zoewangg requested a review from Fred1155 November 19, 2026 17:21
// The HTTP/2 stream manager reports its over-limit rejection as a CrtRuntimeException. Surface it as is, so it
// is not retried, instead of wrapping it in the retryable IOException below.
if (throwable instanceof CrtRuntimeException
&& ((CrtRuntimeException) throwable).errorCode == CRT_STREAM_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider handle 2094 and 2096 error here with a more clear error message? In netty we have

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Updated

Over-limit requests (2094 on HTTP/1.1, 2096 on HTTP/2) now fail with an
IllegalStateException whose message starts with the Netty client's
first sentence, with the CRT error as the cause. It is not retried.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants