Skip to content

Upgrade check: run the MUTATE_PART entries of the killed mutations before the upgrade - #123376

Merged
azat merged 1 commit into
ClickHouse:masterfrom
groeneai:upgrade-check-drain-killed-mutation-entries
Oct 3, 2026
Merged

azat merged 1 commit into
ClickHouse:masterfrom
groeneai:upgrade-check-drain-killed-mutation-entries

Conversation

@groeneai

@groeneai groeneai commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #120978
Related: #121409

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Upgrade check: run the queued MUTATE_PART entries of the mutations killed before the upgrade on the old server, so the upgraded server does not clone a part another replica already mutated.

Description

Upgrade check (amd_release) reds unrelated PRs with CHECKSUM_DOESNT_MATCH ... Data after mutation is not byte-identical to data on another replicas on test_1.v0_r2 (04907_mutation_parts_to_do_deprecated_syntax, 5 PRs since 2026-09-20) and test_1.t_lwu_cleanup_1 (03100_lwu_40_cleanup_race, 4 PRs), e.g. #122715, #121154. Raised on #119196 (comment).

Root cause. Both tests stop merges or fetches on one replica while the other applies a mutation; the stress run interrupts them before the SYSTEM START. The kill step (#120978) kills the mutation, which is unfinished on the stopped replica, but KILL MUTATION leaves that replica's queued MUTATE_PART entries. After the upgrade the entry finds There are no mutations for partition ID ..., clones the part unchanged and fails the commit check against the other replica's mutated part.

Change, in the kill step: before the kill, list the replicas sharing (zookeeper_name, zookeeper_path) with a table holding an unfinished mutation or a queued MUTATE_PART. After it, SYSTEM RESTART REPLICA each one (it waits for a running merge selection, reloads mutations from Keeper and drops the tests' stops), check it is writable, SYSTEM SYNC REPLICA ... PULL, and wait up to 60 s until no MUTATE_PART is queued. The old server then repairs the divergence by a fetch, logged in the stress-phase log, which is not scanned. Operational failures write a FAIL row; leftovers go to undrained_mutation_entries.txt.

Validation. I rebuilt both states on 26.9.8.3, ran the block, and restarted onto master. Without the change the upgraded server logs the CI hash pair 351fbe96.. vs b54e201a.. (3/3) and has different columns hash; with it, none (3/3). Also checked: a never-pulled entry, a broken mutation, nothing to drain (+0.05 s), a failing restart (FAIL row), and no restart pass (reproduces).


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

Version info

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

…fore the upgrade

The pre-upgrade kill step (ClickHouse#120978) kills every mutation that some replica has not finished. When a test
stopped merges or fetches on one replica only (04907_mutation_parts_to_do_deprecated_syntax,
03100_lwu_40_cleanup_race), the other replica has already applied the mutation, and the stopped one still
holds MUTATE_PART entries for it. `KILL MUTATION` removes the mutation node but not those entries. After
the upgrade the restart lifts the stops, the entry finds no mutation ("There are no mutations for partition
ID ..."), clones its source part unchanged, and the commit check against the other replica's mutated part
fails with CHECKSUM_DOESNT_MATCH ("Data after mutation is not byte-identical to data on another replicas"),
which the `<Error>` scan reports. The engine documents this race in both messages and repairs it by
fetching; the scan sees it only because the harness made the upgraded server run the entry.

Before the kill, list every replica that shares (zookeeper_name, zookeeper_path) with a table holding an
unfinished mutation or a queued MUTATE_PART. After the kill and its count check, `SYSTEM RESTART REPLICA`
each of them and check that it came back writable: the restart waits for a running merge selection (so a
selection made before the kill has logged or dropped its entry), reloads the mutations from Keeper (where the
killed ones are gone), and drops the tests' `SYSTEM STOP`s, i.e. the state the upgrade restart would produce.
Then `SYSTEM SYNC REPLICA ... PULL` each, and wait up to 60 s until no replica, read-only ones included, has
a MUTATE_PART queued. The old server thus runs the leftovers: an entry nobody applied clones identically, a
lagging one mismatches once and fetches the mutated part. Operational failures write a FAIL row with the
errors; an entry still queued at the deadline is dumped to undrained_mutation_entries.txt for attribution.

The lagging replica's mismatch is now logged by the old server (clickhouse-server.stress.log, not scanned)
instead of the upgraded one.

Validated on a local rig (26.9.8.3 -> master): the 04907 state reproduces the CI hash pair
351fbe96.. vs b54e201a.. after the upgrade without this change (3/3) and none with it (3/3); the same for the
03100_lwu_40 state ("has different columns hash") and for an entry the lagging replica never pulled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work labels Oct 2, 2026
@groeneai

groeneai commented Oct 2, 2026

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

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (3 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ A drain that reaches its 60 s deadline with entries still queued writes no FAIL row (upgrade_runner.sh:384-405) DISAGREE A leftover that matters fails the commit check on the upgraded server and logs CHECKSUM_DOESNT_MATCH, which the <Error> scan already reports (rig run with the restart pass removed: deadline reached, artifact written, error in the upgraded log). A leftover that does not error has no upgrade consequence; failing on it would red unrelated PRs.
2 💡 A read-only replica that the previous block cannot restart yields two FAIL rows noted The run is red either way.
3 💡 A non-permanently detached replica is not in system.replicas, so it is not drained noted Needs a third replica or a partly applied mutation plus a detach at interruption; none of the 9 CI rows has that shape.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

@clickhouse-gh

clickhouse-gh Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [504a6d3]

Summary: ✅


AI Review

Summary

This PR tightens the upgrade-check cleanup step so killed replicated mutations do not leave stale MUTATE_PART queue entries for the upgraded server to replay. I reviewed the current diff, the PR metadata, the existing discussion, and the current code around SYSTEM RESTART REPLICA / SYSTEM SYNC REPLICA; I did not find an unresolved correctness, safety, or CI-contract issue in the implementation as it stands.

Final Verdict
  • Status: ✅ Approve

@azat azat 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.

Let's try, I like this new mutations check overall, but maybe we need to revise it in general.

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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work manual approve Manual approve required to run CI pr-ci 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