Repository navigation
Conversation
Fetch() runs once per S3 request, so the first fetch could race when one client serves several threads. Move the mutex ChainedProvider already had into the Provider base and hold it in every Fetch() override that touches creds_ or err_, so the first fill is serialized per provider.
c36fe74 to
a5e976e
Compare
|
Caution Review failedFailed to post review comments. GitHub was unavailable or timed out while CodeRabbit was posting the review. Please request a new review later if the pull request still needs one. This happened while posting 2 inline comments. Use Review findings with unconfirmed publication: 1
|
| Layer / File(s) | Summary |
|---|---|
Shared mutex ownership include/miniocpp/providers.h |
Provider gains a protected fetch mutex. ChainedProvider no longer declares its own fetch mutex. |
Lock credential Fetch flows src/providers.cc |
AssumeRoleProvider, WebIdentityClientGrantsProvider, IamAwsProvider, LdapIdentityProvider, CertificateIdentityProvider, and CustomTokenIdentityProvider lock the mutex before their existing checks and fetch flows. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: jiuker
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title "providers: serialize credential fetches" matches the main change. The PR adds a protected fetch_mutex_ to Provider and makes each Fetch() override that touches credentials or error state hold that mutex. It also removes the mutex from ChainedProvider so the chain serializes through the base-class member. The title is short, specific, and uses the same concept as the objectives, so it describes the primary change.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the fetcher's thread,
And guards the creds before they're read.
Six paths now wait their turn in line,
While cached credentials stay in mind.
The rabbit hops, the locks align.
What this does
Fetch()runs once per S3 request, so the first fetch could race when oneminio::s3::Clientserves several threads at once: two callers could bothmiss the cache and fill
creds_/err_concurrently.Providergains amutable std::mutex fetch_mutex_, and everyFetch()override that touches
creds_orerr_holds it for its whole body.ChainedProviderloses its private mutex, which moves to the base class italready needed; a chain and the provider it delegates to now serialize
through the same member.
No public API or ABI change: the mutex is a protected member of a class that
is already not copyable.
Validation
-DMINIO_CPP_TEST=ON: library and tests build.Summary by CodeRabbit