Fix AWS SDK credential provider thread leak in S3PinotFS#17869
Merged
KKcorps merged 1 commit intoapache:masterfrom Mar 13, 2026
Merged
Fix AWS SDK credential provider thread leak in S3PinotFS#17869KKcorps merged 1 commit intoapache:masterfrom
KKcorps merged 1 commit intoapache:masterfrom
Conversation
StsClient and StsAssumeRoleCredentialsProvider were created as local variables in initOrRefreshS3Client(), never stored as fields, and never closed on refresh or in close(). Each leaked provider spawned sdk-cache-* background threads that accumulated indefinitely (observed: 91 threads over 4.6 days on a production controller). - Store StsClient and StsAssumeRoleCredentialsProvider as instance fields - Close old credential resources after building new client (not before, to avoid a window where concurrent S3 operations hit a closed provider) - Synchronize initOrRefreshS3Client() and close() on _clientLock to prevent races between credential refresh and shutdown - Add closeQuietly() helper for safe resource cleanup
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #17869 +/- ##
============================================
+ Coverage 63.25% 63.27% +0.02%
- Complexity 1460 1468 +8
============================================
Files 3190 3190
Lines 192022 192127 +105
Branches 29413 29433 +20
============================================
+ Hits 121455 121564 +109
+ Misses 61056 61052 -4
Partials 9511 9511
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
xiangfu0
reviewed
Mar 13, 2026
| setMultiPartUploadConfigs(_s3Config); | ||
| } catch (S3Exception e) { | ||
| throw new RuntimeException("Could not initialize S3PinotFS", e); | ||
| // Close old resources after new client is live (order: provider → STS client → S3 client) |
xiangfu0
approved these changes
Mar 13, 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.
Summary
StsClientandStsAssumeRoleCredentialsProviderbeing created as local variables ininitOrRefreshS3Client()— never stored as fields, never closed on refresh, and not closed inclose(). Each leaked provider spawnssdk-cache-*background threads that accumulate indefinitely.sdk-cachethreads (1,338 total) on a controller over 4.6 days.initOrRefreshS3Client()andclose()on_clientLockto prevent races between credential refresh and shutdown.Test plan
mvn compilepassesinit(S3Client)path — no IAM role — so they validate no regression on the non-IAM path)