Repository navigation
Fix ADAPTIVE_V2 client close() hang when a queued request's callback … - #7517
Merged
Merged
Conversation
…calls the same client
1 task done
dagnir
reviewed
Nov 5, 2026
dagnir
left a comment
Contributor
There was a problem hiding this comment.
Can we incorporate the reproduction code from the issue as a test as well? We can put it in codegen-generated-classes-test
dagnir
approved these changes
Nov 5, 2026
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.
…calls the same client
Motivation and Context
Fixes #7515. Since #7197 (2.52.0), closing a client that uses
RetryMode.ADAPTIVE_V2can spin forever at 100% CPU if a request queued in the adaptive rate limiter has a dependent that calls the same client.RateLimiterTokenBucketStore.close()evicts every bucket throughLruCache.evictAll(), which closes each value while holdinglistLockand before removing the entry from the map. Closing a bucket fails its queued requests on the closing thread, so their dependents run there too. If a dependent calls the same client, for example theabortMultipartUploadthat multipart copy issues when a part fails,LruCache.get()re-enterslistLockand keeps getting back the evicted entry that is still in the map. The loop never ends, and any other thread that touches the retry strategy, including Netty event loop threads recording a response, blocks on the lock that thread holds.Modifications
RateLimiterTokenBucketStore: marks itself closed before evicting. After that,tokenBucketForScope()returns a pre-closed bucket without touching the cache. A bucket created in the race window as close starts is closed before the pre-closed bucket is returned.LruCache: eviction marks the entry evicted, removes it from the map and LRU list underlistLock, and closes the value only after releasing that lock. This applies toevictAll()and to size-based eviction inget().RateLimiterTokenBucket: drains queued requests under its lock and fails them after releasing it. This coversclose()and the paths where scheduling is rejected inacquireAsync()anddoNotify().Behavior changes
SdkClientExceptioncaused byIllegalStateException: Rate limiter bucket is closed, the same failure requests already queued in the rate limiter get on close. A lookup that completed just before close started still gets the live bucket, which eviction then closes.LruCachecloses evicted values after releasing its internal list lock instead of while holding it, so different evicted values can now be closed at the same time. DuringevictAll(), a concurrentget()can now return a new entry while evicted values are still being closed, where before it waited forevictAll()to finish. This also applies to evictions in the S3 Express identity cache.Testing
Added unit tests.
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License