Skip to content

Do not throw a logical error when an ephemeral node is held by someone else - #114408

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:fix-ephemeral-node-contended-not-logical-error
Sep 23, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:fix-ephemeral-node-contended-not-logical-error

Conversation

@groeneai

@groeneai groeneai commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115818
Related: #113913
Related: #86434

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Activating a replica whose active/is_active node in Keeper is still held by another session is now reported as REPLICA_ALREADY_EXISTS instead of LOGICAL_ERROR, so it no longer aborts the server in debug and sanitizer builds. The same applies when that node is rewritten while it is being removed.

Description

Related: #115818, #113913, #86434

deleteEphemeralNodeIfContentMatches finds the node held by a foreign owner, logs isn't owned by us. Will wait until it disappears, waits 3 * session_timeout_ms, and then threw LOGICAL_ERROR. That is reachable from a single user query: in #115818 one CREATE DATABASE ... ON CLUSTER with literal shard and replica names makes two hosts the same replica, and the loser then aborts every 45s in debug builds. It is also ordinary runtime state, because Keeper drops a dead session's ephemerals only at expiry while activation retries sooner.

It is now reported as REPLICA_ALREADY_EXISTS, which is what the non-distributed path already returns for the same misconfiguration. ABORTED is raised from 66 places in src/, REPLICA_ALREADY_EXISTS from 7 others and every one of them is this same condition, so system.errors still separates an identity collision from a cancelled query. The wait, the control flow and all six call sites are unchanged, and none of them branches on the error code.

The fast-delete branch of the same function had the same defect. tryRemove(path, stat.version) rethrows every code other than ZNONODE as a Coordination::Exception, and a non-hardware one reaches chassert(false) in DDLWorker::initializeMainThread. The reachable code there is ZBADVERSION, since the content of an active node is rewritten in place, and it is now reported the same way. DDLWorker::markReplicasActive repeats that read and versioned removal inline for loopback hosts, where a rewritten node is now skipped like one claimed by another replica.

#115818 itself is not fixed here. The database is still left unusable, only without the abort.

Both directions are verified with TestKeeper unit tests and with the #115818 reproducer as an integration test: on this branch the losing replica logs Code: 253, and with LOGICAL_ERROR restored that test aborts the server.


Workflow [PR]
Sync PR [sync-upstream/pr/114408]

Version info

  • Merged into: 26.10.1.469-master (included in 26.10 and later)

…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.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (adjudicated)

An independent model reviewed this change cold against the ClickHouse review skill, and I
adjudicated its findings against the code. Two rounds; the second, after the fixes below, returned
no findings.

# Finding Verdict
❌ The ABORTED exception unwinds through DDLWorker::processTask, whose EphemeralNodeHolder was armed before ownership was known, so its destructor removes the foreign active node. Disagree (pre-existing, unchanged by this PR). The step this rests on is that the change introduces the unwind. It does not: Exception::handleErrorCode aborts only under DEBUG_OR_SANITIZER_BUILD or abort_on_logical_error (default false), so in a release build LOGICAL_ERROR already unwinds here, and that destructor already performs the same unversioned tryRemove. This change alters behaviour only in debug/sanitizer builds, where the previous outcome was terminating the server from inside the Exception constructor. The holder-lifetime question in processTask is real but independent of the error class and out of scope here.
⚠️ The new test does not pin the promised wait: it would still pass if the deadline wait were skipped. Agree, fixed. The test now asserts a monotonic lower bound on elapsed time, verified by mutating the wait away and confirming that this assertion, and only this assertion, fails. The same finding also asked for coverage through DDLWorker::processTask asserting the foreign node survives; declined, since that pins behaviour this PR does not change.
⚠️ ZooKeeper.h still documents LOGICAL_ERROR for the function this PR changes. Agree, fixed. The declaration comment now names ABORTED.

Also noticed while reviewing, and deliberately not chased here: in DDLWorker::processTask
the EphemeralNodeHolder is armed before the worker knows it owns the node, so on any
throw from the contended branch the destructor removes a node another worker may own. That
is present today in release builds and is not a consequence of this change.

@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e0ed9b7]

Summary: ✅


AI Review

Summary

This PR reclassifies contended or rewritten Keeper active nodes from LOGICAL_ERROR or raw Keeper failures to REPLICA_ALREADY_EXISTS, updates the loopback DDLWorker branch to treat the same version race as non-fatal, and adds unit and integration coverage around the new error path. The error-code change itself is reasonable, but one concurrency bug remains on the exact path this PR turns from an abort into an unwind, so I would not merge it as-is.

Findings
❌ Blockers
  • [src/Common/ZooKeeper/ZooKeeper.cpp:1467-1477, src/Interpreters/DDLWorker.cpp:683-719, src/Common/ZooKeeper/ZooKeeper.h:810-817] [dismissed by author -- https://github.com/Do not throw a logical error when an ephemeral node is held by someone else #114408#discussion_r3772045631] DDLWorker::processTask still arms EphemeralNodeHolder::existing before it knows it owns entry/active/<host>. On the contended path this PR now throws a normal REPLICA_ALREADY_EXISTS exception, so unwinding through ~EphemeralNodeHolder performs an unversioned tryRemove(path) and can delete another worker's active node. That breaks the single-executor contract for distributed DDL: a second worker can observe the node missing and start the same task concurrently. Suggested fix: create or re-arm the holder only after create(active_node_path, ...) succeeds, or explicitly disarm it before deleteEphemeralNodeIfContentMatches and re-arm it after ownership is established.
Tests
  • ⚠️ The new unit and integration coverage does not exercise the DDLWorker::processTask unwind above. A focused regression should pin that timing out on a foreign entry/active/<host> node leaves that foreign node intact.
Final Verdict

Changes requested. The REPLICA_ALREADY_EXISTS remap is fine, but the DDLWorker::processTask holder lifetime bug still lets this new unwind remove a foreign active node.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.30% 87.30% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 55/59 (93.22%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. unit_tests_dbms --gtest_filter="ZooKeeperTest.DeleteEphemeralNodeIfContentMatches*". The blocking node is persistent, so the wait deadline is always reached: 20/20 identical runs, ~600 ms each. The end-to-end arm (planted persistent is_active + server restart) is equally deterministic.
b Root cause explained? Yes. A foreign or not-yet-expired holder is expected runtime state: Keeper drops a dead session's ephemerals only at expiry, and the timeout negotiated in the handshake is stored in Coordination::ZooKeeper's own args copy (ZooKeeperImpl.cpp:790-792) and never propagated to the zkutil::ZooKeeper::args this wait reads (ZooKeeper.cpp:1461). The message names that case and then classified it as a logical error.
c Fix matches root cause? Yes. The defect is the error class, so only the class changes (LOGICAL_ERROR -> ABORTED). No widened bound, no suppressed check, no reduced dataset, no defensive guard. The operation still fails.
d Test intent preserved / new tests added? Yes. No existing test weakened; the 17 pre-existing ZooKeeper/Keeper gtests still pass (19 with the two added here). Two new tests: the foreign-holder case, plus a negative control (matching predicate removes the node and throws nothing) proving the first test reaches the intended branch. The foreign-holder test also pins the wait itself with a monotonic elapsed lower bound (>= 3 * session_timeout_ms, lower bound only so it is not load-sensitive); mutation-checked by making the code throw without waiting, which reddens exactly that assertion (0 vs 600) while the error-code and node-survival assertions stay green.
e Both directions demonstrated? Yes, twice. gtest: pristine build aborts (exit 134) at ZooKeeper.cpp:1462; fixed build passes with e.code() == ABORTED. Live server via ReplicatedMergeTreeRestartingThread: pristine binary dies (client gets Code: 210), fixed binary reports Code: 236 (ABORTED) and retries with backoff. Build IDs asserted on both arms.
f Fix is general across code paths? Yes. Fixed at the single shared throw, so all six call sites are covered at once (StorageKafka2, ReplicatedMergeTreeRestartingThread, DatabaseReplicatedWorker x2, DDLWorker x2), plus the ZooKeeperWithFaultInjection forwarder. StorageKafka2::assertActive is already ABORTED via #113913. The six other LOGICAL_ERRORs in the same file (:347, :2013, :2020, :2024, :2089, :2117) are genuine programming errors and are deliberately unchanged.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A by construction: the change has no data-dependent behaviour. No type wrappers, numeric boundaries or settings interact with it, the condition being a single boolean (tryWait timed out). Both predicate outcomes are covered by the two new tests, and the DatabaseReplicated callers' predicate variant is unaffected because the predicate runs before the throw.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, serialization format, on-disk or wire change, so no SettingsChangesHistory.cpp entry is required. The client-visible code for this condition changes 49 to 236; nothing in src/ or tests/ asserts on the code or the message. In debug and sanitizer builds the behaviour changes from abort to a catchable exception, which is the #113913 precedent.
i Invariants and contracts preserved? Yes. The function still throws on this path, so no caller can mistake failure for success; the ephemeral is not deleted (asserted in the test); activation still refuses to proceed, measured as is_readonly = 1 on the live-server arm, so two servers can never both believe they own the node. No lock, allocation, lifetime or error-path change. Verified that no caller branches on the old code and that nothing newly captures ABORTED on these six paths.

Session id: cron:clickhouse-impl-slot-5:20260812-000300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Michicosun @alesapin, could you review this? ZooKeeper::deleteEphemeralNodeIfContentMatches raised LOGICAL_ERROR when an is_active/active znode is still held by another session, which is expected runtime state, and since LOGICAL_ERROR aborts from the Exception constructor no caller-side catch can absorb it, so the class is changed to ABORTED at the shared site.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 13, 2026
Comment thread src/Common/ZooKeeper/ZooKeeper.cpp Resolved
…test

The arm_tidy build failed with

    gtest_zookeeper.cpp:41:16: error: Value stored to 'started_at' during its
    initialization is never read [clang-analyzer-deadcode.DeadStores]

FAIL() expands to `return GTEST_MESSAGE_(...)` (gtest-internal.h:1295). The
static analyzer does not model the throw edge out of
deleteEphemeralNodeIfContentMatches, so the only path it explores is the one
where the call returns normally and FAIL() returns immediately, leaving
started_at unread. arm_tidy builds with -Werror, so the single diagnostic
failed the job and dropped the rest of the matrix.

Use ADD_FAILURE(), which records the failure without returning, so the store
and its read sit on one linear path. This is the established idiom for the
try/catch "should have thrown" shape in this repository
(gtest_sensitive_data_masker.cpp uses it four times).

The elapsed lower bound is preserved and still load-bearing: replacing the
tryWait condition at ZooKeeper.cpp:1461 with `true` reddens exactly the new
assertion (0 vs 600), and reverting ABORTED to LOGICAL_ERROR still aborts the
test with exit 134.
@@ -1460,7 +1461,7 @@ void ZooKeeper::deleteEphemeralNodeIfContentMatches(const std::string & path, st
int32_t timeout_ms = 3 * args.session_timeout_ms;
if (!eph_node_disappeared->tryWait(timeout_ms))
throw DB::Exception(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turns the timeout into a normal DB::Exception unwind, but DDLWorker::processTask still arms EphemeralNodeHolder::existing(active_node_path, *zookeeper) before it knows it owns /active/<host> (src/Interpreters/DDLWorker.cpp:684-719). On this contended path, unwinding through EphemeralNodeHolder::~EphemeralNodeHolder calls an unversioned tryRemove(path) (src/Common/ZooKeeper/ZooKeeper.h:809-817), so timing out here can delete another worker's active node and break the single-executor contract for distributed DDL. Can we delay creating the holder until after create(active_node_path, ...) succeeds, or at least disarm it before deleteEphemeralNodeIfContentMatches waits and throws?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The holder lifetime defect is real, but this PR does not introduce the unwind it depends on, so it is pre-existing and out of scope here.

abort_on_logical_error defaults to false (src/Core/ServerSettings.cpp:1433) and DEBUG_OR_SANITIZER_BUILD is undefined in release, so Exception.cpp:114 does not abort there: LOGICAL_ERROR already unwound out of deleteEphemeralNodeIfContentMatches in every release build before this change. ~EphemeralNodeHolder (ZooKeeper.h:809-817) is unconditional on the error code, so it already ran the same unversioned tryRemove. DDLWorker.cpp:694 also throws a plain Coordination::Exception through the same armed holder, in all build types, at the pinned merge-base. This PR changes no line in DDLWorker.cpp.

Fixing the holder lifetime means rewriting processTask's ownership window inside a PR whose whole diff is one error code and its test, so I would rather not fold it in. Recorded as a known residual on this PR instead.

This is my second round on this PR, so I will leave further discussion here for a human reviewer.

The message named a session_timeout_ms mismatch or a bug as the only two
explanations, but this branch is reached whenever the node's content does not
match ours, and the ordinary cause is that another live session legitimately
holds it or a previous session's node has not expired yet. Operators reading it
were pointed at a config audit for a condition the code itself anticipates and
waits for.

The foreign owner is now the primary explanation and the timeout mismatch a
secondary one. The error code, the wait and the control flow are unchanged.
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing e0ed9b7df with master d33f21163 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of ab19f7494; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 711.27 MiB 708.22 MiB -3.05 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

9756 translation units recompiled, 14459 s compile time in total, 9322 of them have a recent master baseline.

Translation unit Master PR Δ vs median
contrib/rocksdb-cmake/__/rocksdb/db/version_set.cc 10.1 s 15.9 s +5.4 s (+51%)

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2674bd9

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Bugfix validation (unit tests) harness inconclusive - submodule state differs between the merge-base and the checkout (contrib/AMQP-CPP, contrib/llvm-project, contrib/musl, contrib/silk); this PR changes no submodule (3 files, all under src/Common/ZooKeeper/), so the base branch moved them after the branch split a fix task owns the harness gap (fixing-PR link to follow on this PR)

177 leaves: 151 OK, 25 skipped with a stated reason (reused from cache, not affected by the
changed files, no tests to run, not labeled with pr-performance, no changes in
src/Coordination), 1 ERROR - the row above. Praktika reports 0 dropped jobs, so this run
carries real coverage. No test-level failure on this head.

Session id: cron:our-pr-ci-monitor:20260813-080000

@groeneai groeneai added the groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet label Aug 19, 2026
Ergus
Ergus previously requested changes Aug 26, 2026

@Ergus Ergus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments:

  1. This is intended to be a "Bug Fix", but the PR's says release behaviour is unchanged except for the error code and message text. The abort only ever happened in debug/sanitizer builds, which are not official stable releases.

  2. The sibling PR #113913, used "Improvement" for the identical change class.

    On the other hand, the Bug Fix category is what schedules the Bugfix validation (unit tests) gate that is currently the only red check.

  3. Add the integration test from #115818's reproducer.

Comment thread src/Common/ZooKeeper/ZooKeeper.cpp Outdated
"Ephemeral node {} still exists after {}s, probably it's owned by someone else. "
"Either session_timeout_ms in client's config is different from server's config or it's a bug. "
"Node data: '{}'",
DB::ErrorCodes::ABORTED,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downgrade removes the only signal that catches a real bug reaching this branch, and open issue #115818 is the live proof

Add Related: #115818 to the description. It is the strongest evidence for the change and the clearest statement of what the change does not fix.

Reconsider ABORTED. It is among the most-thrown codes in the codebase, so after this change system.errors no longer distinguishes an identity collision from a cancelled query.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both done in e0ed9b7.

Reconsidered as asked: the code is now REPLICA_ALREADY_EXISTS. ABORTED is raised from 66 places in src/, REPLICA_ALREADY_EXISTS from 7 others, and every one of those 7 is this same condition, including There already is an active replica with this replica path in StorageReplicatedMergeTree and the Replica ... already exists that the non-distributed CREATE DATABASE path in #115818 already returns for exactly this misconfiguration. So system.errors separates it again, and both entrances to the same problem now report the same code.

Related: #115818 is in the description, which also states plainly that this PR does not fix the issue: the database is still left unusable, only without the abort.

On losing the signal: with a code specific to this condition, the retry loop still logs the node path and the owner's ServerUUID on every attempt and system.errors still counts it, and #115818 asks for the same thing it asks of this branch, that a user-reachable misconfiguration should not produce a LOGICAL_ERROR.

{
auto code = tryRemove(path, stat.version);
if (code != Coordination::Error::ZOK && code != Coordination::Error::ZNONODE)
throw Coordination::Exception::fromPath(code, path);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fast-delete branch of the same function still reports a Keeper race in a way that aborts debug builds.

tryRemove(path, stat.version) tolerates ZNONODE but rethrows anything else as Coordination::Exception.

A non-hardware Coordination::Exception lands on chassert(false) at DDLWorker.cpp:1239

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified and fixed in e0ed9b7.

Among the non-hardware codes, tryRemove(path, stat.version) can only return ZBADVERSION there, and it is reachable: the content of an active node is rewritten in place while it is still ours, for instance when DatabaseReplicated strips the unsynced marker (DatabaseReplicatedWorker.cpp:641). It is now reported as the same REPLICA_ALREADY_EXISTS as the wait branch, so it no longer reaches the chassert(false) you pointed at.

DDLWorker::markReplicasActive repeats that read and versioned removal inline for loopback hosts (DDLWorker.cpp:1498), and the copy had the identical problem, reached from the same catch. There a rewritten node is now skipped, which is what the branch already does when another replica claims the host.

The helper's version race is pinned by a TestKeeper test in both directions: with the new branch removed, the assertion sees 999 instead of 253. The loopback copy has no deterministic test. Forcing a write into the window between tryGet and tryRemove needs the first failpoint in DDLWorker.cpp plus an integration test holding it open, which is a larger production change than the four lines it would cover, so I left it out. Happy to add it if you would rather have it.

groeneai and others added 3 commits August 26, 2026 13:36
ABORTED is thrown from 68 places in src/, so system.errors could not tell an identity
collision from a cancelled query. REPLICA_ALREADY_EXISTS is thrown from 7, all of them the
same condition ("There already is an active replica with this replica path" in
StorageReplicatedMergeTree, "Replica ... already exists" in DatabaseReplicated), and it is
the code the non-distributed CREATE DATABASE path already returns for the misconfiguration
in ClickHouse#115818.

The fast-delete branch of the same function had the same defect. tryRemove(path,
stat.version) tolerates ZNONODE but rethrows every other code as a Coordination::Exception,
and a non-hardware Coordination::Exception reaches chassert(false) in
DDLWorker::initializeMainThread, so losing a race aborted debug builds. The reachable code
there is ZBADVERSION: the content of an active node is rewritten in place while it is ours,
for instance when DatabaseReplicated strips the unsynced marker from <replica_path>/active.
Report it as the same runtime condition.

No caller changes behaviour: none of the six branches on the error code, and the
no_sense_to_retry list in DDLWorker::tryExecuteQuery contains neither the old nor the new
code.

Co-Authored-By: Claude Opus 5 <[email protected]>
The reproducer from ClickHouse#115818: CREATE DATABASE ... ON CLUSTER with literal shard and replica
names gives both hosts one database UUID and one replica name, so one host finds
<replica_path>/active owned by the live other one. session_timeout_ms is lowered to 3s so the
wait is 9s instead of 45s.

The test asserts that the losing replica reports Code: 253 and that neither server aborted.
With LOGICAL_ERROR restored at the throw site it fails: the losing node logs
"Logical error: 'Ephemeral node ... still exists after 9s" and dies.

Co-Authored-By: Claude Opus 5 <[email protected]>
…tive

DDLWorker::markReplicasActive repeats the read, compare and versioned removal inline for
loopback hosts, so its ZBADVERSION was still a non-hardware Coordination::Exception reaching
chassert(false) in initializeMainThread. A rewritten node is now skipped, like a node the
branch already skips when another replica claims it.

Also drop the claim that a version mismatch proves foreign ownership: it proves only that the
node changed, and the rewrite that reaches this in practice keeps the same server identity.

Co-Authored-By: Claude Opus 5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements and removed pr-bugfix Pull request with bugfix, not backported by default labels Aug 26, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Round: e0ed9b7

Points 1 and 2, the changelog category: switched to Improvement. Nothing in a release build changes except the error code and the message text, the state #115818 leaves the database in is not fixed here, and #113913 is the precedent for this change class. The Bugfix validation (unit tests) gate disappearing is a consequence of that, not a reason for it: it was scheduled by the Bug Fix category and was failing on a harness condition (submodule state differing between the merge-base and the checkout) that 25 other PRs hit in the same window, so it was not validating this change.

Point 3, the integration test: added as tests/integration/test_replicated_database_active_node_taken. It runs the CREATE DATABASE ... ON CLUSTER 'two_nodes' ENGINE = Replicated(path, 's1', 'r1') from #115818 on two nodes, with session_timeout_ms lowered to 3s so the wait is 9s rather than 45s, and asserts that the losing replica reports Code: 253 and that neither server aborted. It passes on this branch. With LOGICAL_ERROR restored at the throw site it fails, the losing node logging Logical error: 'Ephemeral node .../active still exists after 9s before it dies.

The error code and the fast-delete branch are answered in the two inline threads.

@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 40 queries analysed

This is a coordination-layer change: it only touches ZooKeeper ephemeral-node removal (swapping a LOGICAL_ERROR for REPLICA_ALREADY_EXISTS), DDLWorker.markReplicasActive, and their tests. None of that code runs during a ClickBench SELECT, so the three flagged read-path deltas (Q18 +5.5%, Q32 +6.9%, Q34 +6.4%) cannot plausibly be caused by this PR. Q18 and Q32 are downgraded to not_sure as run-to-run variance; Q34 shows a cleaner, consistent shift but still lands within master's normal variance band and off the changed path, so it stands as not_sure rather than a real regression. No PR-attributable performance change found.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 18 not_sure 1058 1116 +5.5% 0.0376 This PR only changes ZooKeeper ephemeral-node error handling and DDLWorker coordination; a ClickBench SELECT like Q18 never executes that path, so the +5.5% shift is run-to-run variance, not a PR effect.
⚠️ 32 not_sure 1321 1412 +6.9% 0.0005 Same rationale as Q18: the diff touches only DDL/coordination plumbing, which Q32's read path never hits, so the +6.9% delta is unrelated to this PR.
⚠️ 34 not_sure 1203 1280 +6.4% 0.0007 Delta of +6.4% is a clean, consistent shift with low measurement noise, but it sits inside master's normal variance band [517,1383] ms and the PR only changes ZooKeeper/DDL coordination, so it is not attributable to this diff.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 6bb759c5-410a-47ab-97b6-6e2c904c53b4
  • MIRAI run: 8bdde57f-6b00-41a0-b125-6ef282812fcb
  • PR check IDs:
    • clickbench_546702_1788147880
    • clickbench_546870_1788147924
    • clickbench_546971_1788147938
    • tpch_adapted_1_official_547085_1788147962
    • tpch_adapted_1_official_547100_1788147963
    • tpch_adapted_1_official_547114_1788147963

@clickhouse-gh clickhouse-gh Bot added the comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... label Sep 4, 2026
@alexey-milovidov
alexey-milovidov dismissed Ergus’s stale review September 22, 2026 22:32

Concerns resolved.

@alexey-milovidov alexey-milovidov self-assigned this Sep 22, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is alright.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 22, 2026
Merged via the queue into ClickHouse:master with commit 36ce602 Sep 23, 2026
352 of 356 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-keeper ClickHouse Keeper (Raft-based coordination layer; ZooKeeper replacement) and ZooKeeper client lib... groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants