Skip to content

Fix adaptive retries implementation - #7197

Open
dagnir wants to merge 10 commits into
masterfrom
feature/master/adaptive-retries-fixes
Open

Fix adaptive retries implementation#7197
dagnir wants to merge 10 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 and others added 3 commits July 28, 2026 13:44
* Avoid unnecessary schedule

* Fix unnecessary stubbing error

* Additional unnecessary stubbing fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

1 participant