Repository navigation
Remove ACCESS_DENIED and INVALID_ACCESS_KEY_ID from unretryable S3 errors - #109021
JingYanchao wants to merge 3 commits into
Conversation
|
@nickitat Could you please help with a review? Thanks! |
|
@arsenmuk, can you take a look at this one pls. |
|
Workflow [PR], commit [795450b] Summary: ❌
AI ReviewSummaryThis PR stops S3 credential/authentication errors from being treated as permanent part corruption by making Findings❌ Blockers
Tests
Final VerdictRequest changes. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code |
a18daf1 to
0adc3d4
Compare
Build profile diff (arm_release)No arm_release build profile data for commit 795450b - the build was skipped, reused from cache, or predates profile upload. |
0adc3d4 to
c2e265b
Compare
| catch (const S3Exception & s3_exception) | ||
| { | ||
| return s3_exception.isRetryableError(); | ||
| return s3_exception.isRetryableError() || s3_exception.isAccessTokenExpiredError(); |
There was a problem hiding this comment.
This helper is used by startup and ATTACH load paths too, not only by the "do not mark this part broken" sites. In MergeTreeData::loadDataPart, both the part builder and loadColumnsChecksumsIndexes rethrow any exception for which isRetryableException returns true (src/Storages/MergeTree/MergeTreeData.cpp:2550-2574). loadDataPartWithRetries then retries only 3 times and rethrows on the last attempt (src/Storages/MergeTree/MergeTreeData.cpp:2628-2660).
So an ACCESS_DENIED / INVALID_ACCESS_KEY_ID / INVALID_SIGNATURE blip during startup no longer becomes "mark the part broken and keep loading"; after a few hundred milliseconds it aborts ATTACH or table load entirely. That seems worse than the bug this PR is trying to fix, because a delayed credential rotation can now keep the table from loading at all.
I think the relaxed classification needs to stay out of the generic isRetryableException path, or the startup loaders need a separate "not broken, recheck later" handling instead of the current throw-after-3-tries behavior.
| catch (const S3Exception & s3_exception) | ||
| { | ||
| return s3_exception.isRetryableError(); | ||
| return s3_exception.isRetryableError() || s3_exception.isAccessTokenExpiredError(); |
There was a problem hiding this comment.
Making these auth errors retryable also changes checkDataPart semantics: the wrapper swallows any retryable exception and returns empty checksums (src/Storages/MergeTree/checkDataPart.cpp:542-551 and 575-584). Some callers already treat empty() as "could not verify" (src/Storages/MergeTree/DataPartsExchange.cpp:969-978), but the verification paths here do not:
StorageMergeTree::checkDataNextreturnsCheckResult(..., true, "")aftercheckDataPart(...)whenchecksums.txtalready exists (src/Storages/StorageMergeTree.cpp:3458-3462).ReplicatedMergeTreePartCheckThread::checkPartImplignores the return value and logsPart {} looks good.(src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp:401-416).
After this change, an S3 auth failure during verification can therefore be reported as a successful CHECK TABLE or replica part check even though the checksum read was skipped entirely. These callers need an explicit empty() guard, or checkDataPart needs to keep throwing for this class of error.
Relative issue
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix data parts on S3-backed disks being marked as broken after a transient S3 authentication error, such as an expired or rotated credential.
Motivation
S3 access keys are configured via configuration files and support hot-reload, and may also use temporary credentials. Currently, if the access key is
misconfigured or not updated in time, all queried parts that depend on S3 become broken immediately without retry, resulting in significant recovery costs.