Repository navigation
Do not throw a logical error when StorageKafka2 is not active - #113913
Conversation
`StorageKafka2::assertActive` threw `LOGICAL_ERROR` when the table is not active, but the table legitimately becomes inactive whenever the Keeper session expires and `partialShutdown` runs, racing with direct reads (`Kafka2Source::generateImpl`) and materialized-view streaming. In debug and sanitizer builds this aborts the server and shows up in the stress test as `Logical error: Table is not active (replica path: A)`. Throw `ABORTED` instead, resolving the old TODO. Seen in: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112788&sha=ba3438849a503d92dd66f6b64e89ff66c29bf6cc&name_0=PR&name_1=Stress%20test%20%28amd_debug%29 Related PR: #112788 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [325b020] Summary: ✅ AI ReviewSummaryThis PR changes PR Metadata
Missing context / blind spots
Final Verdict✅ No code blockers found. Change the LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 2/2 (100.00%) · Uncovered code |
Build profile diff (arm_release)No arm_release build profile data for commit 325b020 - the build was skipped, reused from cache, or predates profile upload. |
The test drops the Keeper connections, waits until `partialShutdown` has run and reactivation keeps failing, then runs a direct `SELECT` and asserts it fails with `ABORTED` (`Code: 236`) instead of a logical error that would abort the server in debug and sanitizer builds. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@alexey-milovidov the new test is flaky. Could you please take a look at it? |
…e else
zkutil::ZooKeeper::deleteEphemeralNodeIfContentMatches waits for a contended
ephemeral to disappear and threw LOGICAL_ERROR on timeout. That condition is
expected runtime state rather than a broken invariant:
* another live server may legitimately hold the node, which is the whole
reason the content predicate exists;
* the wait can be shorter than the holder's session. Keeper removes a dead
session's ephemerals only at session expiry, and the timeout negotiated
during the handshake is stored in Coordination::ZooKeeper's own args copy
and never propagated to zkutil::ZooKeeper::args, which is the object this
wait reads. The message already names this case and then classified it as
a logical error anyway.
LOGICAL_ERROR calls abortOnFailedAssertion from the Exception constructor
under DEBUG_OR_SANITIZER_BUILD, i.e. before unwinding, so a caller-side catch
cannot prevent the abort and the fix has to be at the shared site. Raise
ABORTED instead. The message, the wait and the control flow are unchanged, so
the operation still fails and activation still refuses to proceed rather than
assuming ownership.
This follows ClickHouse#113913, which chose ABORTED for the sibling condition in
StorageKafka2::assertActive. That covered the direct-read path; this is the
activation path. All six call sites (StorageKafka2, the MergeTree restarting
thread, two in DatabaseReplicatedWorker and two in DDLWorker) already treat a
failed activation as retryable and none of them branches on the error code.
Verified in both directions with a TestKeeper gtest, and end-to-end against a
live server through ReplicatedMergeTreeRestartingThread, where the previous
code terminated the server and the new code reports ABORTED, retries with
backoff and leaves the replica read-only.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Kafka tables with Keeper-stored offsets (
kafka_keeper_path) now throwABORTEDinstead ofLOGICAL_ERRORwhen the table becomes inactive after a Keeper session loss (e.g. during a direct read or materialized-view streaming).StorageKafka2::assertActivethrewLOGICAL_ERRORwhen the table is not active. But the table legitimately becomes inactive at any moment when the Keeper session expires andpartialShutdownruns, racing with direct reads (Kafka2Source::generateImplcallsgetZooKeeperAndAssertActive) and with the materialized-view streaming task. So an inactive table on these paths is an expected runtime condition, not a bug — the code even carried aTODO(antaljanosbenjamin): change LOGICAL_ERROR to something sensible.In debug and sanitizer builds a
LOGICAL_ERRORaborts the server, and this surfaced in the stress test asLogical error: Table is not active (replica path: A):https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112788&sha=ba3438849a503d92dd66f6b64e89ff66c29bf6cc&name_0=PR&name_1=Stress%20test%20%28amd_debug%29
Throw
ABORTEDinstead, consistent with the neighboringTable is detachedexception in the same file.A focused regression test,
test_storage_kafka/test_keeper_session_loss_direct_read.py, forces a Keeper session loss (network partition), waits untilpartialShutdownhas run and reactivation keeps failing, then runs a directSELECTand asserts it fails withABORTEDinstead of a logical error.Related: #112788