Skip to content

Fix adaptive retries implementation - #7197

Merged
dagnir merged 11 commits into
masterfrom
feature/master/adaptive-retries-fixes
Aug 11, 2026
Merged

Fix adaptive retries implementation#7197
dagnir merged 11 commits into
masterfrom
feature/master/adaptive-retries-fixes

Conversation

@dagnir

@dagnir dagnir commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

This is merging the feature branch feature/master/adaptive-retries-fixes to master. The branch fixes the implementation the AdaptiveRetryStrategy to correctly rate limit the client requests under throttling conditions; previously this rate limit was too aggressive (could result in TPS much lower than server TPS), and unstable (rate limited TPS varies over time, even if the server TPS is static).

This branch is a collection of smaller PR's that have been reviewed previously:

Modifications

Testing

Screenshots (if appropriate)

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

License

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

dagnir and others added 7 commits July 14, 2026 17:42
Add acquireInitialTokenAsync and refreshRetryTokenAsync methods to
RetryStrategy interface to better support asynchronous workflows.
* Add acquireAsync

This commit replaces tryAcquire with acquireAsync to better support
async codepaths. acquireAsync returns a CompletableFuture that is
completed when a token is successfully acquired; unlike tryAcquire, the
caller is not expected to do any of their own waiting once future is
complete.

* Additional test

* Evict cache on close

* Address comments
* Wire in acquireAsync in adaptive strat

Implement `DefaultAdaptiveRetryStrategy`'s `acquireInitialTokenAsync`
and `refreshRetryTokenAsync` using the new
`RateLimiterTokenBucket#acquireAsync`. The existing
`acquireInitialToken` and `refreshRetryToken` delegate to these new
methods.

* Review comments
Update the default *Async RetryStrategy methods that delegate to the
sync versions to catch and report any thrown errors through the returned
CompletableFuture.
* Update AsyncRetryableStage + tests

 - Update AsyncRetryableStage to use the new *Async methods from
   RetryStrategy
 - Update AdaptiveRetryRateLimitingTest to test both sync and async
   clients
 - Update other tests to wait on future to avoid timing issues

* Review fixes

 - Remove commented sleep
 - Ensure CompletionException is unwrapped
 - Log non-zero backoff duration

* Return instead of falling thru
@dagnir
dagnir requested a review from a team as a code owner July 27, 2026 21:02
@dagnir dagnir added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Jul 27, 2026
@dagnir
dagnir requested a review from RanVaknin August 10, 2026 18:14
@dagnir dagnir mentioned this pull request Aug 10, 2026
12 tasks
verify(scheduler).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
}


@RanVaknin RanVaknin Aug 10, 2026

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.

non blocking nit:

We don't have a unit test that explicitly tests the happy path:

The integ tests asserts the overall behavior but we probably should have a unit test that verifies that the future is completed successfully, and that capacity was consumed.

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.

Sure will follow up with a PR to add a test.

@dagnir

dagnir commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Waiting for #7248 to get into master before enabling merge.

JackPGreen pushed a commit to JackPGreen/aws-sdk-java-v2 that referenced this pull request Aug 11, 2026
Bump version to 2.52.0 in preparation for releasing the adaptive retries
fixes (aws#7197).
@dagnir
dagnir added this pull request to the merge queue Aug 11, 2026
Merged via the queue into master with commit 882c880 Aug 11, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants