GH-50188: [C++][Python] Release S3 credentials providers in FinalizeS3 #55881
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 412 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.360
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #55881"
general
weight: 0.35
raulcd
Rationale for this change
Since Arrow 24,
finalize_s3()hangs forever if anS3FileSystemusing web identity credentials is still alive, and so does interpreter exit. Web identity credentials meansAWS_WEB_IDENTITY_TOKEN_FILE+AWS_ROLE_ARN, e.g. EKS IRSA. The issue has a deterministic repro using a bogus token.This is a lifetime issue, not a race:
In the bundled AWS SDK 1.11.778,
STSAssumeRoleWebIdentityCredentialsProviderbecame aCrtCredentialsProvider. It's created withGetDefaultClientBootstrap(), so while it is alive it holds a reference to the defaultClientBootstrap. In 1.11.587, used by Arrow 23, it usedSTSCredentialsClientwithout CRT.S3ClientFinalizerreleases allS3Clients beforeAws::ShutdownAPI(), but the credentials provider is also owned byS3Options::credentials_providerandClientBuilder::credentials_provider_. A liveS3FileSystemkeeps it alive, soShutdownAPI()waits forever for the bootstrap reference to go away.This is also why removing
EnableBlockingShutdown()(#50193) is not enough. The wait moves to~ApiHandle→aws_thread_join_all_managed, as reported in the issue.What changes are included in this PR?
FinalizableCredentialsProvider: anAWSCredentialsProviderthat delegates to the wrapped provider and drops it on finalization. After that it returns empty credentials. That isn't reachable through Arrow, because S3 operations already fail with "S3 finalized" at that point.S3ClientFinalizertracks these wrappers (weak refs) and finalizes them after the client holders.S3Options::ConfigureDefaultCredentials()andConfigureAssumeRoleWithWebIdentityCredentials()wrap their providers. These are the ones that can be CRT-based.A provider assigned directly to
S3Options::credentials_providerby C++ users is not wrapped. Its lifetime remains the caller's responsibility.Are these changes tested?
Yes:
A new
test_s3_finalize_with_live_web_identity_fsruns in a subprocess with a timeout and needs no network. It covers both an explicitfinalize_s3()and plain interpreter exit with a live filesystem. It times out without this change and passes with it.The existing S3 tests in
test_fs.pypass against minio.Manually on a Linux build of this branch: the bogus-token repro from the issue now exits.
On an EKS pod with real IRSA credentials (x86_64), reading an object and then exiting works. The released 26.0.1 wheel hangs at exit in the same pod.
Are there any user-facing changes?
Processes using web identity credentials no longer hang in
finalize_s3()or at exit.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by:
AI usage summary:
An AI coding assistant (Claude) helped trace the root cause through the Arrow and AWS SDK sources, wrote the code change, test and description, and ran the builds and repros.
I directed the investigation, reproduced the issue, and validated the fix on EKS with IRSA.
GitHub Issue: Closes #50188