Repository navigation
Docs: document the transaction statements, KILL TRANSACTION, KILL PART_MOVE_TO_SHARD and EXPLAIN CURRENT TRANSACTION - #131664
Conversation
…ILL PART_MOVE_TO_SHARD and EXPLAIN CURRENT TRANSACTION forms `BEGIN TRANSACTION`, `START TRANSACTION`, `COMMIT`, `ROLLBACK` and `SET TRANSACTION SNAPSHOT` had no reference page, and the `KILL` and `EXPLAIN` pages did not mention `KILL TRANSACTION`, `KILL PART_MOVE_TO_SHARD` or `EXPLAIN CURRENT TRANSACTION`, although the parsers accept them. `ParserTransactionControl` gets a `BEGIN TRANSACTION` documentation entry and is registered, so `system.statements` exposes it and the docs autogeneration fills the new `docs/reference/statements/transactions.mdx` page. The `KILL` and `EXPLAIN` entries gain sections for the missing forms. Every page states that the feature is experimental, how it is enabled, and the version each statement was introduced in (measured on the release tags: v22.4.0 for the transaction statements, v24.3.0 for the `START TRANSACTION` alias, v21.11.0 for `KILL PART_MOVE_TO_SHARD`). Every behaviour on the pages was observed on a server built from this branch, and the examples are copied from those runs. The generated regions are left to the autogeneration workflow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Transactions concept page: the example runs `SET async_insert = 0` before `BEGIN TRANSACTION`. With the default `async_insert = 1` its `INSERT ... FORMAT Values` inside the transaction threw `Async inserts inside transactions are not supported`. - `COMMIT`: after a failed query, `ROLLBACK`, `SET TRANSACTION SNAPSHOT` and the `EXPLAIN` queries other than `EXPLAIN ANALYZE` still run; everything else throws `INVALID_TRANSACTION` until `ROLLBACK`. - `KILL TRANSACTION`: the session of a killed transaction is in the same state as after a failed query (links to `COMMIT`), and the statement also needs `SELECT` on `system.transactions`. - `KILL PART_MOVE_TO_SHARD`: needs `SELECT` on `system.part_moves_between_shards`; the two move privileges are needed only to cancel a move. - `SET TRANSACTION SNAPSHOT`: the transaction keeps seeing its own changes, including with snapshot `1`. - The `async_insert` sentence is scoped to `INSERT ... VALUES` and `INSERT ... SELECT`, the paths that were observed to throw. Every changed sentence was checked on a server built from this branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (click to expand)Two review rounds; final head reviewed by both models.
|
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261114-133100 |
|
Workflow [PR], commit [09f035a] Summary: ✅
AI ReviewSummaryPR #131664 documents the experimental transaction control statements, Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes6 object files changed (+38.05 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units13 translation units recompiled, 22 s compile time in total, 13 of them have a recent master baseline. |
…tements `SET TRANSACTION SNAPSHOT`: `MergeTreeTransaction::setSnapshot` only changes the CSN the transaction reads at; `TransactionManager:: snapshots_in_use` still holds the snapshot the transaction started with, and `VersionMetadata::canBeRemoved` compares removal CSNs against the oldest of those. So once no running transaction started before a merge, a mutation or another query removed a part, the part can be deleted, and a transaction that sets an earlier snapshot (even before the cleanup) silently misses its rows. No retention time is promised: a transactional `TRUNCATE` or `DROP PARTITION` bypasses `old_parts_lifetime`. Observed: after a transactional `ALTER TABLE ... DELETE`, the earlier snapshot returns both rows right away and none after cleanup; a background merge alone has the same effect; a transaction that started before the delete keeps the old part. Snapshot `3` also shows the parts of transactions that have not committed yet: `EverythingVisibleCSN` returns before any CSN check, and a second session reads another session's uncommitted insert with it. A query that cannot be parsed or whose query parameters are missing or invalid fails before the scope that rolls the transaction back, so the transaction stays `RUNNING` and a later `COMMIT` commits the earlier writes (observed over HTTP and the native client); analysis and execution errors do roll it back. The concept page's note that every exception prevents the commit is corrected the same way. The `KILL TRANSACTION` section now defers to the `COMMIT` section instead of repeating a broader claim. `KILL PART_MOVE_TO_SHARD ON CLUSTER` checks both move privileges on `*.*`, since the initiator does not know the target tables (`05082_kill_and_system_on_cluster_access_types`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…apshot A non-transactional insert gets `Tx::NonTransactionalTID` and creation CSN 1, which `VersionInfo::isVisible` accepts for every snapshot, and a non-transactional removal hides the part for every snapshot. Observed on a server built from this branch: while a transaction runs, an `INSERT`, `TRUNCATE TABLE` or `ALTER TABLE ... DELETE` from another session outside a transaction changes its next `SELECT`; the same insert inside a committed transaction, or with `implicit_transaction = 1`, does not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse#131664 added the declaration while ClickHouse#126158 enabled modernize-use-nodiscard; each passed CI on its own, together they break the clang-tidy build on master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #131085
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Document the experimental transaction statements
BEGIN TRANSACTION,START TRANSACTION,COMMIT,ROLLBACKandSET TRANSACTION SNAPSHOT, and theKILL TRANSACTION,KILL PART_MOVE_TO_SHARDandEXPLAIN CURRENT TRANSACTIONstatements, in the SQL reference.Description
First of the PRs for the statements without reference documentation that @ Blargian asked for in #131085. These statements parse on master but had no page or section.
ParserTransactionControlgets aBEGIN TRANSACTIONdocumentation entry and is registered, sosystem.statementsexposes it and the docs autogeneration fills the newdocs/reference/statements/transactions.mdx(frontmatter and empty markers, like #131085). TheKILLandEXPLAINentries gain sections for the missing forms. The page is titledBEGIN TRANSACTIONbecause the generator matches the title to the registered name; the sidebar saysTransactions.Each page and section states that the feature is experimental and how to enable it (the badges and note of the transaction functions), and the version it was introduced in: v22.4.0 for the transaction statements, v24.3.0 for the
START TRANSACTIONalias, v21.11.0 forKILL PART_MOVE_TO_SHARD(checked on the release tags). On the transactions concept page, the example now disablesasync_insertfirst, and the note on exceptions names the failures that leave the transaction running.Validation: I checked every behaviour the pages describe on a server built from this branch, and the examples are copied from those runs. Four findings are on the pages: with the default
async_insert = 1, anINSERT ... VALUESorINSERT ... SELECTinside a transaction throws; a query that cannot be parsed or has missing or invalid query parameters does not roll the transaction back, soCOMMITstill commits it;SET TRANSACTION SNAPSHOTto an earlier CSN misses the rows of parts the server has already deleted; and writes outside transactions are visible to the next query of a running transaction. I regenerated the pages withautogenerate_docs.py --write --only 'statement:'and ranlychee_check.py --mode links(0 errors; corrupted anchors are reported),navigation_check.pyandcheck_autogenerated_regions.py; the committed tree contains no generated text.04926_system_statementsfails without the new reference line and passes with it.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131664]
Version info
26.11.1.2369-master(included in26.11and later)