fix: unify all CreateSecret paths under single mutex to prevent write-write conflict#1113
Closed
HaoXuAI wants to merge 3 commits into
Closed
fix: unify all CreateSecret paths under single mutex to prevent write-write conflict#1113HaoXuAI wants to merge 3 commits into
HaoXuAI wants to merge 3 commits into
Conversation
- Trigger secret refresh before SigV4 catalog API calls when refresh_info is present, ensuring REST catalog requests use non-expired STS tokens - Propagate refresh_info to per-table secrets so httpfs can auto-refresh credentials during long-running queries - Add TryRefreshStorageSecret() helper that mirrors httpfs refresh logic using public DuckDB APIs (no cross-extension dependency)
Builds the patched iceberg.duckdb_extension for linux_amd64 and publishes to Artifactory (maps-libs-public) for use by iceberg-insight-server.
…-write conflict Three code paths called CreateSecret on aws_secret concurrently: 1. CreateAWSInput (inline, no mutex, fired on EVERY S3 request) 2. TryRefreshStorageSecret (no mutex) 3. (future) MaybeRefreshSecret When two hit simultaneously → 'write-write conflict on alter with aws_secret' → secret poisoned → all subsequent queries fail until pod restart. Fix: - Replace inline refresh in CreateAWSInput with MaybeRefreshSecret (mutex + 300s time gate) - TryRefreshStorageSecret now uses SIGV4Authorization's shared mutex via accessors - Both paths back off on failure (update last_refresh_time) to prevent cascading retries Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
Three code paths call
CreateSecreton the sameaws_secretconcurrently:CreateAWSInput— inline, no mutex, fired on EVERY S3 requestTryRefreshStorageSecret— no mutex, fired on table accessSIGV4Authorizationinstances sharing the same secret nameWhen two execute simultaneously →
write-write conflict on alter with "aws_secret"→ secret permanently poisoned → all queries fail until process restart.Fix
CreateAWSInputwithMaybeRefreshSecret(static mutex + 300s time gate)TryRefreshStorageSecretshares the same mutex viaGetRefreshMutex()/GetLastRefreshTime()accessorslast_refresh_timeon failure (backs off instead of cascading retries)Reproduction
Any deployment using SIGV4 auth with
web_identitycredential chain under concurrent queries:TransactionContext Error: Catalog write-write conflict on alter with "aws_secret"Testing
Verified on production (Iceberg Insight Server, 2 replicas, ~10 concurrent queries):