Skip to content

Docs: explain what SYSTEM STOP MERGES does not cover - #126337

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
fjvbn2003:docs-system-stop-merges
Nov 1, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
fjvbn2003:docs-system-stop-merges

Conversation

@fjvbn2003

@fjvbn2003 fjvbn2003 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #91183

Changelog category (leave one):

  • Documentation (changelog entry is not required)

What and why

The SYSTEM STOP MERGES section only says that DETACH / ATTACH restarts merges. Four other behaviours surprised us while writing a training lab, so this PR documents them in the documentation registration (src/Parsers/ParserSystemQuery.cpp). The generated region of docs/reference/statements/system.mdx is not edited by hand, following docs/reference/AGENTS.md.

  1. OPTIMIZE TABLE (with or without FINAL) on a plain MergeTree table with stopped merges fails with Cancelled merging parts. (ABORTED). Source: StorageMergeTree::merge checks merges_blocker.isCancelledForPartition() before selecting parts.
  2. SYSTEM STOP MERGES without a table name only locks the tables that exist at that moment. InterpreterSystemQuery::startStopActionInDatabase iterates over the existing tables. Tables created later still merge, which is what SYSTEM STOP MERGES not applying to newly created tables #91183 reports.
  3. SYSTEM STOP MERGES db.t for a table that does not exist yet returns Ok. and has no effect on a table created later under that name. startStopAction uses tryGetTable and does nothing when the table is missing.
  4. The locks live in memory in the ActionLocksManager, so merges run again after a server restart.

The text about OPTIMIZE only claims non-replicated MergeTree. ReplicatedMergeTree takes a different path (log entry plus replication queue), and I did not test it.

How it was checked

ClickHouse 26.8.7.19 (official build, clickhouse-common-static LTS tarball), single server in a Kubernetes pod, run on 2026-10-16 (UTC). Script excerpt and output:

-- A. table-level stop
CREATE TABLE default.t1 (x UInt32) ENGINE=MergeTree ORDER BY x
SYSTEM STOP MERGES default.t1
INSERT x3
OPTIMIZE TABLE default.t1 FINAL  -> Code: 236. DB::Exception: Cancelled merging parts. (ABORTED)
OPTIMIZE TABLE default.t1        -> Code: 236. DB::Exception: Cancelled merging parts. (ABORTED)
active parts: 3

-- B. global stop, then a new table
SYSTEM STOP MERGES
CREATE TABLE default.t2 ...; INSERT x3
OPTIMIZE TABLE default.t2 FINAL  -> Ok, active parts: 1
OPTIMIZE TABLE default.t1 FINAL  -> Code: 236 ... (ABORTED)   (existing table is still stopped)

-- C. stop by name before the table exists
SYSTEM START MERGES
SYSTEM STOP MERGES default.t3    -> Ok.
CREATE TABLE default.t3 ...; INSERT x3
OPTIMIZE TABLE default.t3 FINAL  -> Ok, active parts: 1

-- D. restart
SYSTEM STOP MERGES default.t1; INSERT x2
OPTIMIZE TABLE default.t1 FINAL  -> Code: 236 ... (ABORTED)
(restart clickhouse server)
OPTIMIZE TABLE default.t1 FINAL  -> Ok, active parts: 1

-- E. existing note, re-checked
SYSTEM STOP MERGES default.t2; INSERT x2
OPTIMIZE TABLE default.t2 FINAL  -> Code: 236 ... (ABORTED)
DETACH TABLE default.t2; ATTACH TABLE default.t2
OPTIMIZE TABLE default.t2 FINAL  -> Ok, active parts: 1

This change was drafted with AI assistance and reviewed by me.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.1020-master (included in 26.11 and later)

The SYSTEM STOP MERGES section only said that DETACH/ATTACH restarts
merges. Measured on 26.8.7.19 (single server, plain MergeTree):

- OPTIMIZE TABLE (with or without FINAL) on a table with stopped merges
  fails with "Cancelled merging parts. (ABORTED)"
  (StorageMergeTree::merge checks merges_blocker before selecting parts).
- SYSTEM STOP MERGES without a table name only adds action locks for the
  tables that exist at that moment (startStopActionInDatabase iterates
  the existing tables), so tables created later still merge (ClickHouse#91183).
- SYSTEM STOP MERGES with the name of a table that does not exist yet
  returns Ok and has no effect on the table created later.
- The action locks live in memory, so a server restart starts merges
  again.

The text is the documentation registration in ParserSystemQuery.cpp;
the generated system.mdx region is left to the docs workflow.

Signed-off-by: YoungjuKim <[email protected]>
@CLAassistant

CLAassistant commented Oct 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@clickhouse-gh clickhouse-gh Bot added comp-documentation Documentation (docs, examples, READMEs). external Author is not a member of the ClickHouse organization labels Oct 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [828d126]

Summary: ✅


AI Review

Summary

The PR documents the scope and lifetime of SYSTEM STOP MERGES, its behavior for nonexistent and newly created tables, and its interaction with OPTIMIZE TABLE on non-replicated MergeTree tables. The earlier finding about ON VOLUME is addressed in the current text. No actionable findings remain.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-documentation Documentation PRs for the specific code PR label Oct 20, 2026
@Blargian Blargian added can be tested Allows running workflows for external contributors and removed pr-documentation Documentation PRs for the specific code PR labels Oct 20, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-documentation Documentation PRs for the specific code PR label Oct 20, 2026
Comment thread src/Parsers/ParserSystemQuery.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 828d1269b with master c189bd99f (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 1ee49128d; 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

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

Job report

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

All good. Thank you!

@alexey-milovidov alexey-milovidov self-assigned this Oct 31, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 1, 2026
Merged via the queue into ClickHouse:master with commit 3c4f8ea Nov 1, 2026
179 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 1, 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-documentation Documentation (docs, examples, READMEs). external Author is not a member of the ClickHouse organization pr-documentation Documentation PRs for the specific code PR 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.

5 participants