Skip to content

Docs: document the missing SYSTEM statements - #131679

Merged
Blargian merged 6 commits into
ClickHouse:masterfrom
groeneai:docs-system-statements
Nov 14, 2026
Merged

Blargian merged 6 commits into
ClickHouse:masterfrom
groeneai:docs-system-statements

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131085

Changelog category (leave one):

  • Documentation (changelog entry is not required)

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

Document the SYSTEM statements that had no section in the SQL reference: RELOAD DELTA KERNEL TRACING, RESTART DISK, CLEAR SCHEMA CACHE, FLUSH ASYNC INSERT QUEUE, RECONNECT ZOOKEEPER, RESET DDL WORKER, the JEMALLOC statements, SCHEDULE MERGE, SYNC MERGES, STOP|START CLEANUP, STOP|START VIRTUAL PARTS UPDATE, STOP|START REDUCE BLOCKING PARTS, UNLOCK SNAPSHOT, WAIT QUERY RUNNER and SYNC TRANSACTION LOG.

Description

Second of the PRs for the statements without reference documentation that @ Blargian asked for in #131085: the SYSTEM statements that parse on master but had no section on the SYSTEM page.

The sections are added to documentation["SYSTEM"] in ParserSystemQuery.cpp, which the docs autogeneration turns into docs/reference/statements/system.mdx; the syntax summary in system.statements gets the new forms. Each section has an Introduced in line (the first release whose ASTSystemQuery.h has the statement, checked on the release tags), the experimental badge with the enabling setting named for SCHEDULE MERGE, SYNC MERGES, UNLOCK SNAPSHOT and SYNC TRANSACTION LOG, and the required privilege.

VIRTUAL PARTS UPDATE, REDUCE BLOCKING PARTS and UNLOCK SNAPSHOT are marked as available only in ClickHouse Cloud, with what they do in other builds, and STOP|START CLEANUP as not supported in Cloud; their Cloud behaviour comes from in-tree text (setting descriptions, the snapshot page, test comments), so please correct it if it is wrong. Not documented: SYSTEM DROP AMBER NODE and the three AMBER VOLUME statements (new on master, they fail with Unknown type of SYSTEM query in open-source builds).

Validation: I ran every behaviour the sections describe that an open-source server can execute on a server built from this branch, and the examples are copied from those runs; the rest is read from the source. I regenerated the page with autogenerate_docs.py --write --only 'statement:'; lychee_check.py --mode links reports 0 errors, and a corrupted anchor is reported. check_autogenerated_regions.py passes; the PR contains no generated text.

🤖 Generated with Claude Code


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

Version info

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

groeneai and others added 6 commits November 14, 2026 14:42
Add sections to the SYSTEM reference page (documentation["SYSTEM"] in
ParserSystemQuery.cpp) for the statements that parse but had no section:
RELOAD DELTA KERNEL TRACING, RESTART DISK, CLEAR|DROP SCHEMA CACHE,
FLUSH ASYNC INSERT QUEUE, RECONNECT ZOOKEEPER, RESET DDL WORKER,
JEMALLOC PURGE / FLUSH PROFILE / ENABLE|DISABLE PROFILE, SCHEDULE MERGE,
SYNC MERGES, STOP|START CLEANUP, STOP|START VIRTUAL PARTS UPDATE,
STOP|START REDUCE BLOCKING PARTS, UNLOCK SNAPSHOT, WAIT QUERY RUNNER and
SYNC TRANSACTION LOG, and their forms to the syntax summary.

Each section has an "Introduced in" line (the first release whose
ASTSystemQuery.h has the statement), the ExperimentalBadge where the
statement needs an experimental setting, a Cloud-only note for the three
statements that do nothing or fail in open-source builds, and the
required privilege. Every behaviour sentence was observed on a server
built from this branch.

Related: ClickHouse#131085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- RESTART DISK was introduced in 21.6 (the first 21.6 release tag,
  v21.6.2.7-prestable, has it; v21.5.9.4-stable does not).
- RESET DDL WORKER only requests the reset: the DDLWorker thread
  performs it later, the statement returns at once.
- UNLOCK SNAPSHOT and JEMALLOC FLUSH PROFILE state their own privilege.
- SCHEDULE MERGE: the parts must be adjacent parts of one partition, in
  order; a list that is not is never merged and holds back the merges
  scheduled after it (ManualMergeSelector selects only a contiguous run
  of one parts range and stops at the first entry it cannot select).

Related: ClickHouse#131085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- FLUSH ASYNC INSERT QUEUE: with a table list the statement waits only for the
  batches it takes from the queue itself (AsynchronousInsertQueue::flush), while
  flushAll also waits for in-flight flushes and the pool; an insert whose data
  does not parse is dropped and logged to system.asynchronous_insert_log, and the
  statement still succeeds (observed).
- SCHEDULE MERGE: TTL merges are chosen before the manual selector
  (MergeSelectorApplier::chooseMergesFrom), so they still run on a 'Manual'
  table (observed TTLDropMerge); a scheduled range must also pass the regular
  merge size constraints (checkPreparedRangeAgainstConstraints, observed with
  max_bytes_to_merge_at_max_space_in_pool = 1); the schedule lives in a
  process-local registry and is lost on restart (observed: SYNC MERGES returns
  at once after a restart, parts unmerged).
- STOP|START CLEANUP: CloudNotSupportedBadge, StorageSharedMergeTree has no
  ActionLocks::Cleanup lock.
- UNLOCK SNAPSHOT: the FROM destination is authorized against SOURCES grants
  (READ on S3/AZURE), like RESTORE.

Related: ClickHouse#131085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- RESTART DISK: refreshDataPartsOnce only adds the parts that appeared since
  the last scan (it seeds parts absent from data_parts_by_info) and does not
  detect removed ones (observed: a part dropped by the writer stays in the
  read-only reader's system.parts after the statement).
- SCHEDULE MERGE: the ManualMergeSelector registry is keyed by database, table
  and uuid and renameInMemory does not re-key it, so a table or database rename
  also loses the schedule (observed: SYNC MERGES returns at once after either
  rename, parts unmerged).
- UNLOCK SNAPSHOT: a FROM destination given as a named collection is resolved
  through BackupInfo::getNamedCollection, which also checks NAMED COLLECTION.

Related: ClickHouse#131085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- SCHEDULE MERGE: the ManualMergeSelector registry entry is keyed by database,
  table and uuid and is erased only when the table is dropped, so a rename does
  not lose the schedule: it is not performed under the new name and applies
  again once the table gets its old name back (observed for both a table and a
  database rename: no merge under the new name, the scheduled merge runs at
  once after the rename back).
- STOP CLEANUP: getCleanupLock only cancels the blocker, which the cleanup
  thread checks before each iteration, so a running iteration finishes after
  the statement returns (observed with the
  storage_merge_tree_background_clear_old_parts_pause fail point: the grabbed
  parts were removed after STOP CLEANUP, later outdated parts stayed).
  Statements such as DROP PART remove outdated parts themselves, so only the
  background cleanup is described as stopped.

Related: ClickHouse#131085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- JEMALLOC FLUSH PROFILE: InterpreterSystemQuery::execute hands any query with
  ON CLUSTER to executeDDLQueryOnCluster before building the filename
  pipeline, so each server writes its own profile file and the initiator
  returns the distributed DDL status, as selected by
  distributed_ddl_output_mode (observed: header host, port, status, error,
  num_hosts_remaining, num_hosts_active, no filename; nothing with `none`;
  the server still wrote its .heap file).
- RELOAD DELTA KERNEL TRACING: without USE_PARQUET && USE_DELTA_KERNEL_RS the
  statement throws SUPPORT_IS_DISABLED "Delta Kernel support is not enabled",
  the same note the JEMALLOC sections carry for builds without jemalloc.

Related: ClickHouse#131085

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (rounds 1-7)

Bounce cap reached - published as-is; residual findings listed below (the two rows marked "not changed").

Finding Verdict
⚠️ SYSTEM RESTART DISK introduced in 21.6, not 21.7 (the first 2021 testing tag predates it) AGREE, fixed
⚠️ SYSTEM RESET DDL WORKER only requests the reset; it runs in the background AGREE, fixed
⚠️ SYSTEM UNLOCK SNAPSHOT section did not state its privilege AGREE, fixed
💡 SYSTEM SCHEDULE MERGE needs adjacent parts of one partition AGREE, fixed
💡 SYSTEM JEMALLOC FLUSH PROFILE privilege stated in its own section AGREE, fixed
💡 FLUSH PROFILE writes to /tmp only with the default jemalloc prof_prefix noted, not changed
⚠️ FLUSH ASYNC INSERT QUEUE <tables> waits only for the batches it takes; a failed insert does not fail it AGREE, fixed
⚠️ TTL merges still run on a merge_selector_algorithm = 'Manual' table AGREE, fixed
⚠️ A scheduled merge must also fit the merge size limits; the schedule is not kept after a restart AGREE, fixed
⚠️ STOP|START CLEANUP has no effect on SharedMergeTree (Cloud) AGREE, fixed
⚠️ UNLOCK SNAPSHOT ... FROM also needs the SOURCES grant (READ on S3/AZURE) AGREE, fixed
💡 Syntax summary omits JEMALLOC ENABLE|DISABLE PROFILE DISAGREE: both fail; the summary lists working forms
⚠️ RESTART DISK only adds the parts that appeared; removed parts are not detected AGREE, fixed
⚠️ UNLOCK SNAPSHOT from a named collection also needs the NAMED COLLECTION privilege AGREE, fixed
💡 system.asynchronous_insert_log is optional DISAGREE: the shipped server config enables it
⚠️ SCHEDULE MERGE after a rename of the table or its database: not performed until the table gets its old name back AGREE, fixed
⚠️ STOP CLEANUP does not interrupt a running cleanup, and only the background cleanup stops AGREE, fixed
⚠️ WAIT QUERY RUNNER misses rows still in the async insert queue DISAGREE: those rows are not inserted into the table yet
⚠️ WAIT QUERY RUNNER refuses a lazy_load_tables stand-in DISAGREE: code defect in waitQueryRunner, out of scope for this docs PR
⚠️ SYNC TRANSACTION LOG reads the log without a Keeper sync DISAGREE: code defect in TransactionLog::sync, out of scope for this docs PR
⚠️ JEMALLOC FLUSH PROFILE ON CLUSTER returns the distributed DDL status, not filename AGREE, fixed
💡 RELOAD DELTA KERNEL TRACING fails with SUPPORT_IS_DISABLED in a build without Delta Kernel AGREE, fixed
⚠️ STOP|START CLEANUP, VIRTUAL PARTS UPDATE, REDUCE BLOCKING PARTS without a table skip the tables the user lacks the privilege on; ON CLUSTER without a table needs the global privilege AGREE, not changed: confirmed on a branch build, but the text would push the page literal past the 65,536-byte compiler limit
💡 RECONNECT ZOOKEEPER: the new session is opened by the next ZooKeeper access AGREE, not changed: confirmed on a branch build, same limit
⚠️ SYNC MERGES tracks coverage of the scheduled parts, so a mutation or TTL rewrite can satisfy it without the merge DISAGREE: code defect in ManualMergeSelector, out of scope for this docs PR
💡 The SYSTEM page is one raw string literal of 64,935 bytes (limit 65,536); the next addition must split it, e.g. String(R"DOCS_MD(...)DOCS_MD") + R"DOCS_MD(...)DOCS_MD" noted, not changed

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: none of the 18 new section anchors exists on master's docs/reference/statements/system.mdx; the regenerated page has each.
b Root cause explained? The SYSTEM page is generated from one documentation entry, documentation["SYSTEM"] in ParserSystemQuery.cpp, which never got sections for these ASTSystemQuery::Type members.
c Fix matches root cause? Yes: the sections are added to that entry; no generated region is edited (check_autogenerated_regions.py passes).
d Test intent preserved / new tests added? Documentation text of an existing entry: no new test. 04926_system_statements passes; 04927_system_documentation_statements matches its reference once the absolute build path of source is stripped (local build without path mapping).
e Both directions demonstrated? Yes, for the docs checks: a corrupted anchor is reported by lychee_check.py, a corrupted anchor inside a <Note> and a removed component import are reported by link and import scripts, and a hand edit in the generated region fails check_autogenerated_regions.py; all pass on the real tree.
f Fix is general across code paths? Every ASTSystemQuery::Type member without a section on today's master is either documented here or listed as not documented (test helpers and the forms with no open-source implementation).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (documentation). Each documented behaviour was run on a server built from this branch, including the variants the text names: with and without a table, with and without the privilege, with the feature enabled and disabled, after a restart.
h Backward compatible? (maintainer-approved exception only) Yes: documentation strings only; no behaviour, setting or format change.
i Invariants and contracts preserved? Yes: page title unchanged, every new header has a unique anchor, every used component is imported, every added link resolves on the regenerated pages.

Session id: cron:clickhouse-impl-slot-6:20261114-140304

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0f66dea]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

The PR adds reference documentation for previously undocumented SYSTEM statements without changing execution behavior. Three documentation concerns remain at 0f66dea6699809de42fe057ac1473872091cbc42. All were already discussed and deliberately left unchanged, so no duplicate inline findings were posted.

Findings

⚠️ Majors

  • src/Parsers/ParserSystemQuery.cpp:1932 — SYSTEM SYNC MERGES does not guarantee that the scheduled merges executed. ManualMergeSelector::isAllScheduledPartsCovered considers a scheduled source finished whenever a differently named active part contains it (src/Storages/MergeTree/Compaction/MergeSelectors/ManualMergeSelector.cpp:161–167). Mutations can rewrite the sources separately and satisfy this condition while multiple parts remain. Users cannot rely on the documented completion guarantee when coordinating manual merges. Describe the coverage condition and its mutation/TTL limitation, or link a tracked fix. [dismissed by author -- https://github.com/Docs: document the missing SYSTEM statements #131679#issuecomment-6883672386] The implementation defect can be handled separately, but the new documentation still promises stronger behavior than it provides.

  • src/Parsers/ParserSystemQuery.cpp:2553 — SYSTEM SYNC TRANSACTION LOG does not establish the promised visibility of every earlier remote commit. TransactionLog::sync lists the log with getChildren and waits only for the greatest commit sequence number returned (src/Interpreters/TransactionLog.cpp:736–746), without a Keeper sync fence. With the default quorum_reads = false, a lagging Keeper follower can omit a completed commit from another session; waiting for the older sequence number then returns without loading that commit. Qualify the guarantee as loading the commits observed by this read, or link a tracked fix for the missing fence. [dismissed by author -- https://github.com/Docs: document the missing SYSTEM statements #131679#issuecomment-6883672386] Deferring the implementation fix does not make the unconditional cross-server visibility claim accurate.

  • src/Parsers/ParserSystemQuery.cpp:2025, 2042, 2059 — The privilege descriptions omit materially different behavior when the table is omitted. For CLEANUP, VIRTUAL PARTS UPDATE, and REDUCE BLOCKING PARTS, local execution silently skips unauthorized tables (InterpreterSystemQuery::startStopActionInDatabase), whereas execution with ON CLUSTER and no table requires the corresponding global privilege (InterpreterSystemQuery::getRequiredAccessForDDLOnCluster). Table-scoped grants therefore produce partial local execution or a cluster-wide access exception, rather than the single privilege contract described here. Document these two cases together. [deferred by author -- https://github.com/Docs: document the missing SYSTEM statements #131679#issuecomment-6883672386] The acknowledged omission remains relevant to operators using these commands for maintenance.

Missing context / blind spots
  • ⚠️ The private implementations of the Cloud-only statements are unavailable in this checkout. Their descriptions were assessed against the in-tree snapshot documentation, settings, and action registrations; Cloud implementation review would close this gap.
Final Verdict

⚠️ Request changes. Qualify the two synchronization guarantees and document the omitted-table privilege behavior. These require documentation corrections, not implementation changes in this PR.

@clickhouse-gh clickhouse-gh Bot added the pr-documentation Documentation PRs for the specific code PR label Nov 14, 2026
@Blargian Blargian added the can be tested Allows running workflows for external contributors label Nov 14, 2026
@Blargian
Blargian enabled auto-merge November 14, 2026 20:55
@Blargian

Copy link
Copy Markdown
Member

@groeneai as a separate fix - it should not be necessary to explicitly import badges inside the .cpp definition. We should handle these transparently so that the generator inserts them at the start of the inside of the autogenerated block. Open a PR with a fix for this and remove all explicit imports in the code where they exist. The components can still be used, e.g. <BetaBadge/> but it should not be necessary to make the imports in the same code description.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Acknowledged. I'm working on making the docs generator insert the snippet-component imports itself at the start of the autogenerated block, and removing the explicit imports from the source registrations; I'll follow up here with the PR link.

@clickhouse-gh clickhouse-gh Bot added the comp-documentation Documentation (docs, examples, READMEs). label Nov 14, 2026
@Blargian
Blargian added this pull request to the merge queue Nov 14, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Opened #131704: the generator now inserts the import of every badge a generated region renders at the start of that region, and the 57 explicit badge imports are removed from the source registrations. It is stacked on #130905, so it should go in after #130905 and #130608. The one import this PR adds in ParserSystemQuery.cpp stays harmless with the new generator, which inserts no duplicate.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 0f66dea

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
Build profile diff infra, not from this PR: the job stopped before any comparison, because all 8 readiness probes (SELECT 1) to the CI logs cluster hit the 3 s read timeout and it raised LogClusterNotReady: the endpoint never became ready in has_pr_data. The same error hit 11 other PRs between 20:51Z and 22:01Z #129675 (mine, open)

Session id: cron:our-pr-ci-monitor:20261114-233011

Merged via the queue into ClickHouse:master with commit 52d3d52 Nov 14, 2026
567 of 572 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 15, 2026
zoomxi pushed a commit to zoomxi/ClickHouse that referenced this pull request Nov 17, 2026
A Mintlify page must import every badge it renders. `replace_between_markers`
wrote the generated content verbatim, so the only place such an import could
come from was the documentation string itself: 57 `import { XBadge } ...`
lines in 44 descriptions, 12 of them for badges the page never renders, all
visible in `system.documentation`.

`replace_between_markers`, the placement point of every marker family and
of the statement pages, now prepends at the start of the region one
`import { XBadge } from "/snippets/components/XBadge/XBadge.jsx";` per
`*Badge` tag the new content renders that the resulting page does not import
yet. The old region is not consulted (it holds the previous generation's
imports); the text outside the region and the new content are, so function
category pages that import their badges above the region, and doc strings
that still carry an import, get no duplicate. Imports follow first use. The
split settings pages keep their own derivation.

Remove the badge imports (and the blank line after each group) from the doc
strings. Retarget 04415 (TimeSeries renders `<PrivatePreviewBadge/>` without
importing it) and 05023 (full-page detection past an MDX import: the polygon
layout's snippet import). The two dictionary page self-tests now compare
through `replace_between_markers`, so they model the inserted imports.

Full `--write` A/B (old script + old binary vs new script + new binary):
26,348 of 26,358 docs files byte-identical; 6 pages drop the 12 unused
imports, 3 pages reorder imports by first use, and
`beta-and-experimental-features.mdx` reorders rows, which also happens
between two runs of the old generator.

Related: ClickHouse#131679

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

can be tested Allows running workflows for external contributors comp-documentation Documentation (docs, examples, READMEs). 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.

3 participants