Repository navigation
Conversation
At startup or on ATTACH, MergeTreeData::loadDataPart marks a part broken for any error isRetryableException does not recognise. An object store not-found is deliberately classified as non-retryable there: S3 NO_SUCH_KEY is listed in unretryable_errors, and isRetryableAzureException retries only transport errors, a provisioning-window 403 and >= 5xx. So a part whose object load hits a not-found gets exactly one attempt and is then detached as broken-on-start. The bounded retry that loadDataPartWithRetries already implements (3 tries, 100 ms to 5 s backoff) never engages for this class, because loadDataPart returns is_broken rather than throwing, so its caller's catch is unreachable. A fix confined to the wrapper would therefore be dead code; the classification has to happen in loadDataPart, where the exception is still in hand. That is also why retry_not_found is a parameter: only the wrapper knows whether attempts remain, while only loadDataPart can choose between rethrowing and marking the part broken. Consequence on default settings: max_suspicious_broken_parts is 100, so one broken part does not trip the threshold and goes straight to the detach. Plain MergeTree on object storage has no recovery path, and with allow_remote_fs_zero_copy_replication the GET_PART fallback has no independent copy to fetch from. The part's rows disappear from query results after a restart while its objects are still present in the bucket. A not-found now gets its own disposition on the Active load path: while attempts remain it is rethrown so the existing budget retries it, and on the final attempt it falls through to the existing mark_broken() and detach. A transient not-found heals; a persistent one keeps today's behaviour, which is what test_azure_broken_parts (added by ClickHouse#62306) pins - a deleted blob must still yield a successful ATTACH plus a detached part. Scope notes. src/IO/S3Common.cpp is not touched: unretryable_errors is consulted by every S3 caller, including existence probes and cache lookups where 404 is the correct answer, which is why ClickHouse#109021 removed ACCESS_DENIED and INVALID_ACCESS_KEY_ID but kept NO_SUCH_KEY. NO_SUCH_BUCKET is excluded from the new predicate, so S3::isNotFoundError is not reused wholesale: a missing bucket is a whole-storage condition rather than a per-object one. Only the Active state is affected - the PreActive refresh never detaches and its caller reschedules, and loadOutdatedDataParts operates on parts already pending removal and terminates the server if a load throws. Validated with a new integration test that injects a real HTTP 404 NoSuchKey through the existing S3 mock, which fails without this change and passes with it, plus controls for no fault, a not-found outlasting the budget, and a corrupt part. test_azure_broken_parts, test_cache_bypass_on_disk_failure and test_retry_loading_parts remain green.
Review round 1 follow-up to the object-store not-found retry. Drop RESOURCE_NOT_FOUND from isObjectStorageNotFoundException. It is not in unretryable_errors (src/IO/S3Common.cpp), so S3Exception::isRetryableError() already returns true for it: a transient one is absorbed by the existing retryable budget and a persistent one already rethrows out of loadDataPartWithRetries. Because should_rethrow tests isRetryableException first, that arm of the predicate could never be reached, and covering it also contradicted the header's claim that the predicate is disjoint from isRetryableException. The predicate now matches only what unretryable_errors actually classifies as non-retryable, so that claim holds and no arm changes behaviour. Correct the Active-gate comment. It said PreActive and Outdated never detach here, which is false for Outdated (loadOutdatedDataParts detaches, as does loadUnexpectedDataParts). The real reason the gate is needed is stronger: the Outdated caller terminates the server if a load throws, and the PreActive caller reschedules. Make the two control tests assert what their comments claim, using the retry log lines handle_exception already emits. test_persistent_not_found_at_part_load now asserts the budget was really exhausted, so it fails if the implementation gives up an attempt early - previously the leftover armed fault was cleared by fail_request(0) and the test could not see the bound it guards. test_corrupted_part_still_detached now asserts zero absorbed retries, which is what actually proves the retry is scoped to not-found rather than widened to every load failure; the terminal state alone was satisfied even when every error was retried.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 findings across 2 passes,
Severity: ❌ blocker / Also noticed and deliberately not chased: Session id: cron:clickhouse-review-slot-8:20260810-142200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260810-134502 |
|
cc @CheSema @rschu1ze, could you review this? A part load that hits an S3 |
|
Workflow [PR], commit [a0a25a0] Summary: ✅
AI ReviewSummaryThe PR retries S3 Missing context / blind spots
Final VerdictStatus: ✅ Approve. No additional code changes requested. |
Style check `catch_all` flagged the terminal `catch (...)` as a silent swallow. The swallow is correct here and cannot mislabel a fault: - the function is a pure classifier that takes `exception_ptr` by value, so the caller still owns the exception; `rethrow_exception` plus a catch chain is the only way to type-dispatch an `exception_ptr`, which makes the terminal catch-all structural to the idiom rather than a loss of information; - a retryable fault can never reach it, because `should_rethrow` in MergeTreeData.cpp tests `isRetryableException` first and returns early; - nothing goes unlogged: on `false` the caller falls through to `mark_broken()`, which calls `tryLogCurrentException` with the part name and path, exactly as before this change. Removing the catch-all is not an option (an unrelated exception would escape a `bool` predicate) and neither is rethrowing (it would propagate out of a classifier), so the accepted in-tree remedy applies: the immediate sibling `isRetryableException` in this file has the same catch-all-returns-false shape and passes the linter on its comment alone. Comment only, no behaviour change.
The Azure arm keyed on HTTP 404 alone, but Azure answers 404 for a missing container as well as a missing blob, distinguishing them only in `ErrorCode` (preserved on the exception in contrib/azure/sdk/storage/azure-storage-common/src/storage_exception.cpp, and keyed on this way by the SDK itself in blob_client.cpp). A vanished container is a whole-storage condition, so treating it as a per-object not-found would spend the per-part retry budget, with its backoff sleep, on every active part at startup. The S3 arm already excludes the analogous `NO_SUCH_BUCKET`; this makes Azure consistent with it. Also drop an inaccurate half-claim from the `should_rethrow` comment: the `PreActive` caller does not itself reschedule. Background refresh reschedules in `refreshDataParts`, while `SYSTEM RESTART DISK` calls `refreshDataPartsOnce` directly and propagates to the user, so the comment now states only what is true of every non-Active caller.
|
Pushed
I kept the The re-review also caught a real defect: the Azure arm keyed on HTTP 404 alone, but Azure answers 404 for a missing container too, distinguishing it only in
Transient recovery is proven for S3 only: that fixture owns a mock endpoint this PR extended, and there is no equivalent Azure fault-injection proxy in the tree. |
The part-load path now retries an object store not-found while attempts remain, so loadColumnsChecksumsIndexes could log "Part ... is broken and needs manual correction" for a part that then attaches successfully. That line asks the operator to intervene and feeds broken-part alerting, so a healed load must not emit it. A not-found carries no evidence about the part's contents, which is the same reason the existing guard already skips a retryable error, so extend that guard rather than threading the retry intent down. Measured with a bounded GET 404 against a MergeTree on S3, comparing the pre-fix binary: faults arm count() detached "needs manual correction" 1 pre-fix 1 0 1 1 post-fix 1 0 0 2 pre-fix 1 0 2 2 post-fix 1 0 0 3 pre-fix 0 1 3 3 post-fix 0 1 0 The terminal case keeps its diagnostics: mark_broken still logs the reason via tryLogCurrentException plus "Detaching broken part" (measured on the persistent arm: the reason line and the NoSuchKey text are both present). Reverting the new predicate restores 1 and 2 lines on the healed arms, so the guard is what suppresses them.
Two gaps in the tests, both found by review: The S3 transient test checked recovery but not diagnostics, so reverting the log guard left every test green. It now asserts the healed load emits no "needs manual correction" error. Reverting the guard fails it with 1 == 0. The Azure arm of the classifier had no test that fails when it stops matching: the merged broken-parts test deletes the blob permanently and asserts only the final state, which is identical with or without retries. A deleted blob is a 404, so the retries do happen and are logged; the test now asserts both absorbed attempts and the absent broken-part error. This needs no fault injection, so it works with the Azurite fixture as it is. Making the Azure arm match HTTP 410 instead fails it with 0 > 0, and the S3 test still passes, so the assertion is specific to that arm.
Only the builder and loadColumnsChecksumsIndexes failures reach mark_broken. A later failure, such as reading txn_version.txt, is thrown past both catches and the wrapper rethrows it on the final attempt, which is the pre-existing loud outcome and is left as is. Drop the parenthetical that named marking the part broken as the only settlement.
CI finish ledger - 677427dEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
The flaky-check reds are setup errors of one shared module fixture, not assertion failures: the with frames This is not caused by the change under review, even though the diff does touch The hung check is a separate trunk defect. Breadth over 30 days, for attribution only: the azure module signature is 178 rows across 3 pull Session id: cron:our-pr-ci-monitor:20260811-090000 |
|
Ledger correction for the `Integration tests (amd_asan_ubsan, flaky)` line above: that failure has an external fixing PR, #103394, so it is owned by that PR rather than by a fix task. I also had the mechanism wrong. It is not an Azurite readiness race. `generate_cluster_def()` writes the disk config to a fixed path `_gen/disk_storage_conf.xml` with the Azurite port baked in, but the port is allocated per xdist worker and the flaky check runs with `--dist=each`, so all workers write that one file and the last writer wins. The two losing workers then dial the winner's port and get `e.code() = 111, Connection refused` in `IDisk::checkAccess`. From this run's artifacts:
gw0/gw1's own Azurite was healthy and serving the harness the whole time, and the module has 18 tests, which is exactly the 36 errors (18 x 2 losing workers). #103394 fixes this by generating the file per worker. No change is needed on this PR. |
|
@groeneai It is not clear what you try to fix. Please reference the CI issue or issue or problem that this PR addresses. |
|
@rschu1ze There is no issue and no CI failure behind it: I found this by inspection and reproduced it with a fault-injecting fixture, so there was nothing to link. Fair complaint though, so I rewrote the description to lead with the defect. A The object is intact and a further restart does not bring the rows back. #110724 and #114023 are the same misclassification at other sites, now linked; this fixes neither. I can open a tracking issue for this one if you prefer having it filed. |
|
Fixing PR for the hung |
…not-found-on-active-part-load # Conflicts: # src/Storages/MergeTree/IMergeTreeDataPart.cpp # src/Storages/MergeTree/MergeTreeData.cpp # src/Storages/MergeTree/MergeTreeData.h # src/Storages/MergeTree/checkDataPart.cpp
CI finish ledger - 818680eEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The Session id: cron:our-pr-ci-monitor:20261024-183004 |
…not-found-on-active-part-load Resolve the checkDataPart.cpp conflict: keep master's isQueryCancellation (ClickHouse#128083) and add isObjectStorageNotFoundException after it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units18 translation units recompiled, 201 s compile time in total, 18 of them have a recent master baseline. |
Related: #110724
Related: #114023
Related: #109021
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes data loss where a data part on object storage is permanently detached as
broken-on-startbecause the object store momentarily answers "not found" (S3NoSuchKey, Azure HTTP 404) while the part is loading. Such a not-found is now retried within the existing part loading budget, so a transient one no longer costs the part. One that persists is still detached, as before.Description
No issue reports this. I found it by inspection and reproduced it with a fault-injecting fixture. The linked issues are the same misclassification elsewhere; this fixes neither.
What breaks: a
MergeTreeon object storage with one committed part, restarted while the store answers a single 404 for it.The object is intact, yet no later restart brings the rows back.
test_transient_not_found_at_part_loadcovers it: fails on master, passes here.Cause:
loadDataPartmarks a part broken for any errorisRetryableExceptiondoes not recognise except an I/O error (#127381), and a not-found is deliberately non-retryable there (NO_SUCH_KEYis inunretryable_errors; Azure never retries a 404). So the part gets one attempt, andloadDataPartWithRetriesnever engages becauseloadDataPartreturnsis_broken. One broken part does not reachmax_suspicious_broken_parts = 100, so it detaches at once; under zero-copy replicationGET_PARThas no other copy.A not-found on the active loading path is now rethrown while attempts remain, like an I/O error, so the existing budget (3 tries, 100 and 200 ms apart) retries it; the last attempt detaches as before. Later phases keep their loud failure.
Scoped deliberately:
src/IO/S3Common.cppis untouched: every S3 caller reads that set, including existence probes where 404 is correct (see Remove ACCESS_DENIED and INVALID_ACCESS_KEY_ID from unretryable S3 errors #109021).NO_SUCH_BUCKETand a missing Azure container are excluded as whole-storage conditions; only theActiveload retries.loadColumnsChecksumsIndexesno longer logs "needs manual correction" for a not-found: it asks the operator to act while saying nothing about the contents. A part given up on still logs its reason and detach.loadUnexpectedDataPart(Do not terminate the server on retryable errors while loading outdated parts #107091),loadPartRestoredFromBackup(own retry loop),loadProjections(degradation, not loss).Controls: no fault, a persistent not-found, a corrupt part.
Workflow [PR]
Sync PR [sync-upstream/pr/114180]