Repository navigation
Make CHECK TABLE retry retryable errors instead of reporting a broken part - #109465
Conversation
… part On a healthy part, the only way `CHECK TABLE` returns 0 (part reported broken) is a thrown exception. Transient/retryable errors - most notably ZooKeeper hardware errors such as connection loss or session expiration on a `ReplicatedMergeTree` table - were silently converted into a "broken" result at two catch sites: - `StorageReplicatedMergeTree::checkDataNext` had a blanket `catch (const Exception &)` that returned `CheckResult(name, false, ...)`, unlike `StorageMergeTree::checkDataNext` which already re-throws retryable exceptions. - `InterpreterCheckQuery::TableCheckTask::checkNext` also blanket-caught and returned a false result for every storage. This is the false-negative behind the chronic flaky `test_broken_projections/test.py::test_mutation_with_broken_projection` (#63002): aggressive background merges add ZooKeeper/IO churn that raises the transient-error rate on the first `CHECK TABLE`. Now both catch sites re-throw retryable exceptions (via `isRetryableException`), so a transient error surfaces as a retryable query error instead of a spurious 0. The interpreter catch still swallows the shutdown `ABORTED` exception it was originally added for (`isRetryableException` treats `ABORTED` as retryable, so it is excluded explicitly). Adds a `check_table_inject_retryable_zk_error` failpoint and a stateless regression test that injects a transient ZooKeeper error during `CHECK TABLE` and asserts it throws rather than returning a broken row for a healthy part. Related: #63002 Related: #107290 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [43d98f1] Summary: ✅
AI ReviewSummaryThis PR changes Missing context / blind spots
Final Verdict✅ No new inline findings. |
Address review from @tiandiwonder: the `check_table_inject_retryable_zk_error` failpoint is placed only inside `StorageReplicatedMergeTree::checkDataNext`. Under `--replace-replicated-with-shared` the table becomes `SharedMergeTree`, which has its own check path and never triggers the failpoint, so the expected `KEEPER_EXCEPTION` would not fire and the test would fail. Tag the test `no-shared-merge-tree` so it is skipped in that mode. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| /// retried, instead of silently reporting a healthy part as broken (returning a "0" row). | ||
| /// The shutdown ABORTED exception is still swallowed here (that is what this catch was originally added | ||
| /// for); `isRetryableException` treats ABORTED as retryable, so exclude it explicitly. | ||
| if (e.code() != ErrorCodes::ABORTED && isRetryableException(std::current_exception())) |
There was a problem hiding this comment.
optional: add a test pinning the ABORTED-swallow behavior — it's the one changed branch the new test doesn't reach, and this exclusion looks like a removable special case to a future cleanup.
There was a problem hiding this comment.
Good point about the coverage gap. Leaving this as a follow-up rather than folding it into this PR: the ABORTED swallow is pre-existing shutdown behavior (this PR does not introduce it — it only narrows the catch so that retryable non-ABORTED errors are rethrown), and pinning what CHECK TABLE returns while the server is shutting down is a separate semantic question from the retryable-error fix here. The now-explicit comment documents why the != ABORTED guard exists, which should deter an accidental removal in the meantime. Leaving the thread open so the follow-up test is not lost.
…ng lines Apply @tiandiwonder's optional simplification suggestions on #109465: the `CHECK TABLE` retry comments in `InterpreterCheckQuery::TableCheckTask::checkNext` and `StorageReplicatedMergeTree::checkDataNext` restated what the code does. Keep only the load-bearing rationale (why transient errors are rethrown, and why the shutdown `ABORTED` exception stays swallowed). Comment-only change; no behavior change.
… TABLE errors
This PR makes `CHECK TABLE` rethrow retryable exceptions (including the
ZooKeeper connection-loss `KEEPER_EXCEPTION`) instead of reporting a spurious
broken part, so the integration test `test_check_replicated_does_not_block_shutdown`
no longer always observes a `0` result when ZooKeeper is killed mid-check.
Once the ZooKeeper session is lost the abort now surfaces in one of two ways,
depending on which condition wins the race:
* the transient error is rethrown from `checkDataNext` (retryable), so
`CHECK TABLE` fails with `KEEPER_EXCEPTION`; or
* the replica's partial shutdown makes the check swallow the `ABORTED` and
return `0`.
Both are acceptable: the invariant this test protects is that `CHECK TABLE`
aborts quickly instead of scanning every part. Accept both outcomes while
keeping the timing assertion.
Surfaced by the `CH Inc sync` job (private sync PR
ClickHouse/clickhouse-private#63397): "Integration
tests (amd_asan_ubsan, db disk, old analyzer, 4/7)".
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Updating the branch to fix the |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 21/23 (91.30%) · Uncovered code |
…ng lines Apply @tiandiwonder's optional simplification suggestions on ClickHouse#109465: the `CHECK TABLE` retry comments in `InterpreterCheckQuery::TableCheckTask::checkNext` and `StorageReplicatedMergeTree::checkDataNext` restated what the code does. Keep only the load-bearing rationale (why transient errors are rethrown, and why the shutdown `ABORTED` exception stays swallowed). Comment-only change; no behavior change.
…y-retryable-errors Make CHECK TABLE retry retryable errors instead of reporting a broken part
CHECK TABLEon aReplicatedMergeTreetable could report a healthy part as broken (return0) when it hit a transient, retryable error — most notably a ZooKeeper hardware error such as connection loss or session expiration — during the check.On a healthy part the only way
CHECK TABLEreturns0is a thrown exception, and two catch sites silently converted retryable exceptions into a "broken" result:StorageReplicatedMergeTree::checkDataNexthad a blanketcatch (const Exception &)that returnedCheckResult(name, false, ...), unlike the non-replicatedStorageMergeTree::checkDataNextwhich already re-throws retryable exceptions.InterpreterCheckQuery::TableCheckTask::checkNextalso blanket-caught and returned a false result for every storage.Both catch sites now re-throw retryable exceptions (via
isRetryableException), so a transient error surfaces as a retryable query error instead of a spurious0. The interpreter catch still swallows the shutdownABORTEDexception it was originally added for (isRetryableExceptiontreatsABORTEDas retryable, so it is excluded explicitly).This is the underlying false-negative behind the chronic flaky
test_broken_projections/test.py::test_mutation_with_broken_projection: aggressive background merges add ZooKeeper/IO churn that raises the transient-error rate on the firstCHECK TABLE.A new
check_table_inject_retryable_zk_errorfailpoint and the stateless test04506_check_table_retryable_zk_errorinject a transient ZooKeeper error duringCHECK TABLEand assert it throws rather than returning a broken row for a healthy part.Related: #63002
Related: #107290
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
CHECK TABLEon aReplicatedMergeTreetable reporting a healthy part as broken when a transient, retryable ZooKeeper error (e.g. connection loss) occurred during the check; such errors are now surfaced as a retryable query error instead.Version info
26.7.1.569(included in26.7and later)