Skip to content

Upgrade check: restart the previous release before killing the stress phase's mutations - #124532

Open
groeneai wants to merge 3 commits into
ClickHouse:masterfrom
groeneai:upgrade-check-restart-before-mutation-kill
Open

groeneai wants to merge 3 commits into
ClickHouse:masterfrom
groeneai:upgrade-check-restart-before-mutation-kill

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122577
Related: #120978
Related: #123841

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: restart the previous release before killing the mutations left by the stress phase, so the kill also reaches tables that an unfinished DETACH left detached.

Description

Upgrade check (amd_release) failed on #122577 with Error message in clickhouse-server.log: 297 <Error> lines of one throwIf(1) mutation: report. Requested by @ alexey-milovidov in #122577 (comment).

Root cause. 01160_table_dependencies.sh was still running DETACH DATABASE on the shared stress database when the stress phase ended, and had already detached the table of 04341_broken_mutation_part_log_flush with its broken mutation. system.mutations lists only attached tables, so the kill step found nothing and reported OK. A DETACH without PERMANENTLY keeps the metadata, so the upgraded server attached the table again and retried the mutation for the whole log window.

Change. Restart the previous release once, right before the kill step. A restarted server attaches every table its metadata lists, as the upgraded server will, so the kill also sees the mutations of tables an unfinished DETACH left detached. The restart also ends the queries the stress phase left running. The system.tables hang probe before it now records a failure, as the restart would otherwise hide a hang there. Cost: one previous-release startup (about 10 s). Trade-off: the restart also lifts the in-memory SYSTEM STOP ... of interrupted tests, so the work they held (merges, fetches, pending Distributed batches) may run on the previous release before the upgrade instead of on the upgraded server.

Validation. Local rig, 26.9.12.8 upgraded to master, throwIf(1) mutations on a detached table, a detached database, a database partly detached by an in-flight DETACH DATABASE, and an attached control: without the change 3/3 runs report OK and the upgraded server logs 45 FUNCTION_THROW_IF_VALUE_IS_NON_ZERO errors per detached table; with it 3/3 runs kill all four mutations and log none.


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

… phase's mutations

The kill step added by ClickHouse#120978 reads `system.mutations`, which lists only the
tables the old server holds attached. A `DETACH` without `PERMANENTLY` that the
stress phase did not undo keeps the table's metadata, so the upgraded server
attaches the table again and resumes its mutation. On ClickHouse#122577,
`01160_table_dependencies.sh` was still detaching the shared stress database
when the stress phase ended; the kill step reported no unfinished mutation, and
the upgraded server retried a `throwIf(1)` mutation of
`04341_broken_mutation_part_log_flush` for the whole log window (297 `<Error>`
lines).

Restart the previous release once before the kill step, with the script's own
`stop_server 300 false` / `start_server`. The restarted server holds what its
metadata lists, the same state the upgrade loads, so the kill sees every
mutation the upgrade would resume. The restart also ends the queries left
running by the stress phase (the case ClickHouse#123841 handles with `KILL QUERY`). The
60 s the stop waits for leftover queries moves from the final stop to this one,
so the added time is one previous-release startup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 8, 2026
@groeneai

groeneai commented Oct 8, 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 ⚠️ CI cannot prove deterministically that the restart exposes detached mutations DISAGREE Local rig: same kill section, base vs patch, detached table / detached database / in-flight DETACH DATABASE: base 3/3 false OK + 45 errors per table, patch 3/3 all killed, 0 errors
2 💡 Description overstated "every mutation" (a replica failing its first init after the restart, a table the old release cannot re-attach) AGREE Description reworded to what the restart guarantees
3 💡 Restart lifts interrupted tests' SYSTEM STOP ..., so held work may run before the upgrade AGREE Stated as the trade-off in the description
4 💡 A Tables count hang no longer yields kill-step FAIL rows DROPPED 0 such hangs in CIDB since #120978

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

Session id: cron:clickhouse-review-slot-10:20261008-010231

@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Local rig (26.9.12.8 upgraded to master), throwIf(1) mutations on a detached table, a detached database and a database partially detached by an in-flight DETACH DATABASE: the unpatched kill step reports OK and the upgraded server logs 45 errors per detached table, 3/3 runs.
b Root cause explained? Yes. system.mutations lists the tables the old server holds attached; the upgraded server loads what the metadata lists. A DETACH without PERMANENTLY left by the stress phase makes the two differ.
c Fix matches root cause? Yes. Restarting the previous release before the kill step makes its in-memory state equal to its metadata. No allow-list entry, no test change.
d Test intent preserved / new tests added? Yes. The <Error> scan stays as strict as #120978 made it; the kill, replica restart, drain and the deliberate cross-upgrade mutation are unchanged.
e Both directions demonstrated? Yes. Without the inserted lines 3/3 runs red; with them 3/3 runs kill all four mutations and log 0 such errors.
f Fix is general across code paths? Yes. Only upgrade_runner.sh has this kill step; the restart covers detached tables, detached and partially detached databases, and leftover queries (#123841).
g Fix generalizes across inputs (params/datatypes/wrappers)? Atomic and Ordinary databases exercised; for replicated tables the system tables wait for table startup, which loads the replica's mutations.
h Backward compatible? (maintainer-approved exception only) N/A, CI script only.
i Invariants and contracts preserved? A failed stop or start exits as the existing calls do. The restart's log goes to the stress log, which the <Error> scan does not read; the critical-error scan still covers it.

Session id: cron:clickhouse-impl-slot-6:20261008-002300

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [002d95a]

Summary: ✅


AI Review

Summary

This PR makes upgrade_runner.sh restart the previous-release server before unfinished-mutation cleanup so system.mutations sees tables that a non-PERMANENTLY DETACH left detached, and it restores an explicit FAIL row when the post-stress system.tables probe times out. I reviewed the diff, the surrounding lifecycle code, and all prior discussion; the earlier bot concern about masking the hang detector is fixed in tests/docker_scripts/upgrade_runner.sh:178, and I do not see a remaining correctness or CI-signal issue in the current patch.

Final Verdict
  • Status: ✅ Approve

@groeneai
groeneai requested a review from maxknv October 8, 2026 01:38
@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 8, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Oct 8, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 10, 2026
Comment thread tests/docker_scripts/upgrade_runner.sh Resolved
The `system.tables` probe after the stress phase only collected gdb.log and
force-stopped the server when it hung. The kill step's queries then failed
against the stopped server and reported it, but the restart of the previous
release added before the kill step brings the server back, so a 10-minute
hang there would pass unnoticed. Record a failure row in that branch, as the
shutdown hang check in stress_tests.lib does.

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

groeneai commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Two more Upgrade check (amd_release) reds of this class since this PR opened, both on unrelated PRs: 2026-10-26, 2026-11-01. In both, the last ATTACH DATABASE of a test's detach/attach cycle on the shared stress database failed (01160_table_dependencies.sh on a table with a positional GROUP BY 1 projection, 01254_dict_load_after_detach_attach.sql on an Elasticsearch table), so the database stayed detached and the kill step saw no unfinished mutation. The upgraded server attached it at startup and retried the leftover mutations of 04338_on_fly_mutation_read_overwritten_lc_source.sql for the whole log window. This is the detached-database case the restart here handles.

This branch has not been deployed

No deployments
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-request PR origin: a maintainer pinged or directed groeneai manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants