Skip to content

Do not fail reads of system.part_moves_between_shards when a replicated table has no Keeper tree - #122132

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-part-moves-between-shards-missing-task-node
Sep 28, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-part-moves-between-shards-missing-task-node

Conversation

@groeneai

@groeneai groeneai commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed SELECT from system.part_moves_between_shards and KILL PART_MOVE_TO_SHARD failing with Code: 999 ... No node, path .../part_moves_shard when any replicated table on the server is attached without its Keeper tree.

Description

On 26.8.11.37, SELECT ... FROM system.part_moves_between_shards - and KILL PART_MOVE_TO_SHARD, which reads it - fail with Code: 999 ... No node, path .../part_moves_shard whenever any replicated table on the server is attached without its Keeper tree, which is an intended read-only state rather than an error.

Root cause. Such a table stays attached in read-only mode instead of failing to attach (ReplicatedMergeTreeAttachThread.cpp:158-163), and that early return skips the createNewZooKeeperNodes() back-fill, so it has no part_moves_shard node for the life of the server. syncStateFromZK() read that node with the throwing getChildren, and StorageSystemPartMovesBetweenShards::fillData has no per-table isolation, so one degraded table aborted the whole query for every user. Only database and table are pushed down, so avoiding it means naming it, which KILL PART_MOVE_TO_SHARD WHERE task_uuid = ... cannot.

Fix. Read it with tryGetChildren, which suppresses only ZNONODE (ZooKeeper.cpp:487-492), so connection loss, session expiry and auth failures still propagate. No part_moves_shard node means no part-move tasks, so an empty snapshot is the true answer. Single site: syncStateFromZK() is the only reader of that path, and all three callers go through it.

Surface Status
system.part_moves_between_shards, KILL PART_MOVE_TO_SHARD fixed
write side (MOVE PART TO SHARD) unchanged, still refused with TABLE_IS_READ_ONLY before any create
system.replicas / replication_queue / mutations / detached_parts verified unaffected
per-entry get at :104 unchanged: needs a concurrent DROP, not reproducible without a new failpoint

Validation. New test red before / green after; the reported failure reproduced byte-for-byte and green after; 50 runs each of it, 05082, 04077, 02841 and 04831, interleaved, in a randomized and a non-randomized arm (500 runs), no failures.

Failing CI job: https://github.com/ClickHouse/ClickHouse/actions/runs/36044079089/job/107790703975 (report)


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

Version info

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

groeneai and others added 2 commits September 24, 2026 23:10
…ed table has no Keeper tree

A replicated table whose Keeper tree is absent stays attached in read-only mode
rather than failing to attach: ReplicatedMergeTreeAttachThread::runImpl logs
"No metadata in ZooKeeper for {}: table will stay in readonly mode", sets
has_metadata_in_zookeeper = false and returns early. That early return skips
createNewZooKeeperNodes(), whose asyncTryCreateNoThrow back-fills
<zookeeper_path>/part_moves_shard, so such a table has no task node for the
life of the server.

PartMovesBetweenShardsOrchestrator::syncStateFromZK() read that node with the
throwing getChildren, and StorageSystemPartMovesBetweenShards::fillData has no
per-table isolation, so the ZNONODE from one degraded table aborted the entire
query for every user with Code: 999. KILL PART_MOVE_TO_SHARD is implemented as
exactly that read and cannot prune by task_uuid, since only database and table
are pushed down, so the statement was unusable server-wide as well.

Read the node with tryGetChildren instead. It suppresses only ZNONODE and
rethrows every other code, so connection loss, session expiry, operation
timeout and auth failures still propagate unchanged. An absent
part_moves_shard node means no part-move tasks, so the empty snapshot is the
true answer, and it is published through the existing entries = new_entries
exit rather than a new return path.

The write side is unaffected: movePartitionToShard calls
getZooKeeperAndAssertNotReadonly() before creating a task znode, so MOVE PART
TO SHARD on such a table is still refused with TABLE_IS_READ_ONLY.

Observed on 26.8.11.37 in Stateless tests (amd_asan_ubsan, distributed plan,
parallel), where a concurrently attached treeless table made
05082_kill_and_system_on_cluster_access_types fail.

Co-Authored-By: Claude Opus 5 <[email protected]>
The test's only part-move observable was absence: it expects zero rows from
system.part_moves_between_shards and targets the zero UUID with KILL
PART_MOVE_TO_SHARD, which cannot match. An implementation that never issues
the listing at all therefore satisfies the reference for free. Deleting the
zk->tryGetChildren call and leaving the empty Strings behind publishes the
same empty vector through the same exit, so the reference still matches and
the test stays green.

Assert through system.zookeeper_log that the List on the absent path was
issued and was answered ZNONODE. The predicate uses count() > 0 rather than
an exact count because the number of List requests per query is not
contractual, and it carries no op_num predicate because makeListRequest maps
to List, SimpleList, FilteredList or FilteredListWithStatsAndData depending
on Keeper feature flags. The path is unique per run via
CLICKHOUSE_TEST_ZOOKEEPER_PREFIX, so the assertion stays parallel-safe and
nothing else ever touches that path for this table.

The explicit SYSTEM FLUSH LOGS zookeeper_log is required because the log's
flush_interval_milliseconds is 7500.

Measured three ways on one rig: green on the fix 10/10; red on a mutant with
the listing call deleted, where the new assertion prints 0 while the other
two still match; red on the pristine base with Code 999 on both reads.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex). Two cold passes: one on the fix
(1 finding), one on the fix round (0 findings). Bounded: 1 full pass + up to 5 fix rounds + 1
final round.

# Sev Finding Verdict Evidence / action
1 ⚠️ The regression test would still pass if the Keeper listing were removed outright: its only observable is an empty task set (05257_part_moves_between_shards_without_keeper_tree.sh:22-24) AGREE, fixed @ 5e986e4 It now also asserts through system.zookeeper_log that the listing on the absent path was issued and answered with no such node, proven by mutation rather than by argument: with only that one call deleted, the third assertion goes from 1 to 0 while the other two still match. The suggested positive control carrying a real pending move is not reachable from a stateless test, so it was rightly not attempted.
2 💡 Nothing in the tree exercises a non-empty system.part_moves_between_shards Noted, not blocking Pre-existing and not widened here: getChildren is tryGetChildren plus an error check, so the success path is unchanged by this diff. Covering it needs a two-shard integration test, which does not exist today.
3 💡 The per-entry get at PartMovesBetweenShardsOrchestrator.cpp:104 can still throw Noted, not blocking Listed in the surface matrix in the description. The orchestrator never removes a task node, so reaching it needs a concurrent drop of the whole table, which I could not reproduce without adding a failpoint.
4 💡 The new assertion could in principle be satisfied by the orchestrator's background loop instead of by the two reads under test DISAGREE (self-raised, refuted) run() returns before any listing unless part_moves_between_shards_enable is set, and it defaults to 0. getEntries() and getEntryByUUID() both force a sync unconditionally, so the logged ZNONODE is attributable only to the two reads the test performs.
5 💡 The new assertion's timing was defended probabilistically Noted, not blocking It is in fact deterministic: the Keeper client records the operation before invoking the callback that unblocks the waiting query, so the row is queued before the read's result can reach the client, and the following SYSTEM FLUSH LOGS must include it.

Cost of reading system.zookeeper_log in CI, measured rather than assumed: the four existing
in-tree readers of that table ran 880,736 times over 30 days with 4 failures, and none of them
needs a tag to do so. The new assertion adds about 2 seconds against a 180 second slow-test
threshold, so no long tag.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by a fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-8:20260925-003800

@clickhouse-gh clickhouse-gh Bot closed this Sep 25, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 25, 2026
@groeneai
groeneai requested review from azat and tavplubix September 25, 2026 01:05
@clickhouse-gh

clickhouse-gh Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5e986e4]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 6/6) FAIL Performance dashboard
serialization_pool_lookup #0 FAIL dashboard

AI Review

Summary

This PR changes PartMovesBetweenShardsOrchestrator::syncStateFromZK to tolerate a missing /part_moves_shard node by using tryGetChildren, so SELECT from system.part_moves_between_shards and KILL PART_MOVE_TO_SHARD no longer fail when a replicated table is attached read-only without its Keeper tree. The behavior change matches the contract of the affected surfaces, the new shell test exercises both reads, and I did not find a remaining contract violation in the touched code.

Final Verdict

Status: ✅ Approve

LLVM Coverage Report

Measured on commit 5e986e4.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.80% +0.10%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 4/5 (80.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Sep 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 5e986e4da with master c68449eaa (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 16 s compile time in total, 7 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 5e986e4

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
Performance Comparison (arm_release, master_head, 6/6) / serialization_pool_lookup #0 false red of the dashboard gate: 3 too long; 1 confirmed regression(s) on the performance dashboard, client_time 0.6578 -> 0.7759 (+17.9%), tier text Repeated PR measurements show a slowdown. The shard's own report names no slower query, so the dashboard verdict was the only red-maker. That query is noisy for everyone: over 14 days it measures slower on 40 and unstable on 25 other pull requests, plus 92 rows on runs with pull_request_number = 0. This PR cannot reach it either: the fixture aggregates a Dynamic key over numbers_mt to contend on the serialization pool, while the only source change here is one getChildren -> tryGetChildren call inside PartMovesBetweenShardsOrchestrator::syncStateFromZK, reachable only from the part-moves orchestrator ClickHouse/performance-comparison#5, which the gate author names as where noisy queries are handled, in the dashboard's confidence scoring. Rule 3d checked for the repository-side half #121847 (merged 2026-09-23 23:29Z) at the tree this job actually built (d0dbd962695d, 4 hits against 0 pre-fix and 4 at the fix), so it is present and not the owner: its threshold-fetch arm did not fire (historical-thresholds.tsv present and consumed, no fetch warning) and its UTC-timestamp arm cannot (the shards ran 03:21 to 04:39 UTC, same UTC date locally)
Mergeable Check, PR rollup: red only because of the row above, no independent failure ClickHouse/performance-comparison#5

All 176 checks accounted for (134 pass, 39 not selected, Config Workflow, Finish Workflow and
CH Inc sync green), the last one completed at 05:37:33Z. An earlier attempt on this same head was
cancelled and superseded, so its Finish Workflow red is not the live one. CIDB carries no FAIL or
ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20260925-060048

@alexey-milovidov alexey-milovidov self-assigned this Sep 28, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 28, 2026
Merged via the queue into ClickHouse:master with commit e823efc Sep 28, 2026
174 of 349 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 28, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 28, 2026
…alized-query-plan-112891

Picks up ClickHouse#122132, which fixes the 05082_kill_and_system_on_cluster_access_types failure in Stateless tests (arm_binary, parallel) on 101ef90.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov could you add v26.3-must-backport here?

05082 is on all four active release branches through the #118360 backports, but this fix is on none of them: 26.3, 26.7, 26.8 and 26.9 still use the throwing getChildren, so the test can fail there the same way (it did once on 26.8). It also affects master's Upgrade check, whose previous-release server is 26.9.8.3: in this run that server's DDLWorker retried 05082's KILL PART_MOVE_TO_SHARD ... ON CLUSTER entry 224 times on this exception until shutdown, so the upgraded server had to replay every ON CLUSTER entry queued behind it.

The label expands to exactly those four branches, and the source change applies cleanly on each.

clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request Oct 3, 2026
…e log scan

Stress worker 1 (`--database=test_1`) runs with
`memory_tracker_fault_probability=0.05`. Work that the stress phase leaves
behind keeps the settings of the query that created it and is executed again
by the upgraded server after the restart:

- a distributed DDL entry stores the initiator's changed settings
  (`DDLLogEntry`) and `DDLTaskBase::makeQueryContext` applies them, so a
  queued `BACKUP ... ON CLUSTER` of `test_1` replays with fault injection and
  `BackupsWorker` logs `Failed to make internal backup ... fault injected` at
  `<Error>`;
- a pending `Distributed` batch is sent with its stored settings, and the
  receiving async-insert flush logs `AsynchronousInsertQueue: Failed insertion
  ... fault injected` at `<Error>` with an empty query id, so the existing
  `} <Error> executeQuery: Code:` entry does not cover it.

Seen on three unrelated PRs in 90 days (ClickHouse#123464, ClickHouse#117943, ClickHouse#120725); in each job
these lines were the only output of the scan. Nothing enables fault injection
on the upgraded server itself, so the message can only come from carried-over
stress work. Ignore it as a fixed string, the same string the stress smoke
check already tolerates (`ci/jobs/scripts/stress/stress.py`). It is
MemoryTracker's message for both injection sites and does not match a real
`memory limit exceeded` error.

The large DDL backlog in the ClickHouse#123464 job comes from the previous release
(26.9) wedging its DDLWorker on `KILL PART_MOVE_TO_SHARD ... ON CLUSTER`,
which ClickHouse#122132 fixed on master only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release can be tested Allows running workflows for external contributors comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-bugfix Pull request with bugfix, not backported by default 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.

3 participants