Repository navigation
Add author column to system.mutations - #103395
EilRoviSoft wants to merge 65 commits into
Conversation
|
Please edit the title and use the description template. |
|
Needs a test. |
author column to system.mutations
|
Workflow [PR], commit [aaa5f8f] Summary: ❌
AI ReviewSummaryAdds optional mutation-author persistence and the Findings❌ Blockers
Tests
Missing context / blind spots
Final VerdictStatus: ❌ Block Reject truncated transaction markers and include settings publication in rollback protection, with focused regression coverage. |
…or` field Both the on-disk `MergeTree` mutation file and the `ReplicatedMergeTree` mutation znode now advertise `format version: 2` when the `author` field is written, and the readers accept both versions, so a binary that does not know about `author` fails with an explicit `UNKNOWN_FORMAT_VERSION` error instead of a confusing parse error.
…USTER` caveat For `ALTER ... ON CLUSTER` queries the recorded author is the user under which the query was executed on each host, which is the local default user unless the server setting `distributed_ddl_use_initial_user_and_roles` is enabled.
In a `Replicated` database an `ALTER` is executed by the DDL worker, whose query context does not carry the initiating user (unless `distributed_ddl_use_initial_user_and_roles` is enabled), so no author is recorded. Tag the tests that check the recorded author with `no-replicated-database`. `04825_replicated_persist_mutation_author_no_mix`: a `Replicated` database rejects mixing replicated and non-replicated `ALTER` commands earlier with `QUERY_IS_PROHIBITED`, so accept it as well. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103395&sha=latest&name_0=PR PR: ClickHouse#103395 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=103395&sha=latest&name_0=PR&name_1=Integration%20tests%20(arm_binary%2C%201%2F4) ( The other failures (author tests under |
|
This is fixed by #125448 (mine), merged 2026-10-13 01:47 UTC. The failed run tested ff3996e merged into master e83d574 (2026-10-12 20:58 UTC), which does not contain the fix. It matches the #125448 mechanism. Since #120519 (2026-10-12), Since the merge, master has 103 passing runs of this test and 1 failure, on 3ab409c, which predates the fix. The 7 PR failures since 05:00 UTC, this one included, all tested a master without it. The run for ffe4692 merges into 2ca8bd9, which includes the fix. |
# Conflicts: # src/Storages/System/StorageSystemMutations.cpp
Master is now `26.11`, and the setting has not been released yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l settings or comment change In `StorageReplicatedMergeTree::alter`, `getMutationAuthor` could throw `TOO_LARGE_STRING_SIZE` only after a mixed `MODIFY COMMENT` / `MODIFY SETTING` had already been committed locally, leaving the local change without the replicated `ALTER` and its mutation. Compute the mutation commands and the author before that commit and reuse the author when filling the entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An `UPDATE` in the same query runs as a separate `mutate` segment after `alter`, so it does not go through the fixed path. A column type change creates the mutation inside the replicated `ALTER` entry, which is the case that used to leave the local comment change committed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
@groeneai, thanks for confirming that the Iceberg failure was fixed by #125448. This merge includes that fix. |
…ntil the mutation entry is created The lock was declared in the `if` initializer and released right after the check, so a settings `ALTER` could publish a transient `persist_mutation_author` value in memory before `startMutation` read it. A failed enabling `ALTER` could then leave a `format version: 2` mutation file behind. Keep the lock through `startMutation`, as the replicated path does, and cover the interleaving where the mutation passes the lock check before the settings `ALTER` starts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=103395&sha=b110acc068fadfb76c1fb21c07dbb28bde1fda52&name_0=PR&name_1=Stress%20test%20%28amd_msan%29 ( |
|
Confirmed, this is the bug #126492 fixes. The stack is Not caused by this PR: the same abort hit the Stress tests of 12 other PRs in the last 30 days. |
…ring the mutation The previous commit held the lock through all of `startMutation`, including the in-memory registration. `05331_mutation_not_skipped_before_registration` (new on `master`) pauses a mutation right before registration and expects a concurrent `ALTER TABLE ... DROP COLUMN` to proceed; with the lock held it timed out with `DEADLOCK_AVOIDED`. Split `startMutation` into `prepareMutationEntry`, which decides the entry format (`persist_mutation_author`) and writes `mutation_*.txt`, and `registerMutation`. Only the preparation runs under the `ALTER` lock, so a settings `ALTER` still cannot change the format between the check and the write, while the registration no longer blocks `ALTER` queries, as on `master`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=103395&sha=4b25adc960a1467eb4e56d4a8a9ba980467423c4&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20sequential%29 PR: ClickHouse#103395 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion_commands` `master` now computes `maybe_mutation_commands` in `StorageReplicatedMergeTree::alter` before the settings/comment change, to check for non-deterministic virtual columns. The PR computed it at the same point for `getMutationAuthor`; keep a single definition. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Pushed 9b82da7:
Locally, with embedded Keeper, the 9 author tests and |
|
Follow-up on the 02369 |
…part files after the upgrade After the restart, the upgraded server executes a MERGE_PARTS or MUTATE_PART entry whose result the other replica already committed under the previous release. checkPartChecksumsAndCommit compares the new part with the ZooKeeper part header written by the old release. Releases change the byte format of uncompressed part files: statistics.packed is registered with file_hash only, so it lands in the "hash of uncompressed files" bucket, and its content changed in 26.7 (auto_statistics_types default) and in 26.11 (ClickHouse#123950 adds the sum to basic statistics). The task then logs CHECKSUM_DOESNT_MATCH at error level, removes the local part and fetches the replica's part. The upgrade guide (docs/guides/oss/update.mdx) documents this message as expected while replica versions differ, and the statistics author confirmed it on ClickHouse#130674, but the post-upgrade log scan treated it as a failure. Filter the line only when "hash of uncompressed files doesn't match" is the sole clause. Divergent column data ("uncompressed hash of compressed files"), both clauses together, a different number of files and the KILL MUTATION "different columns hash" case still fail the job. The Upgrade check is the only CI job that reports these lines (the stress tests scan only "<Error>.*Application"), so a broader filter on "is not byte-identical to data on another replicas" would remove the only CI detector of divergent column data after replicated merges and mutations. Validated by running the extracted scan on the Upgrade check log of ClickHouse#130547 (1 line -> 0) and on 7 control lines (7 -> 5, every other shape kept), with GNU grep 3.11 locally and inside clickhouse/stress-test. Changing "Code: 40" to "Code: 41" in the new pattern restores both results. Related: ClickHouse#103395 Related: ClickHouse#130674 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict resolutions: - `FailPoint.cpp`: keep both sides' fail point declarations. - `MergeTreeMutationEntry.cpp`: `master` moved the serialization into `writeRecord`, which `writeCSN` now also uses to rewrite the whole record. The `author` field and the `format version: 2` choice moved into `writeRecord`, so the author survives a CSN rewrite. - `StorageMergeTree.cpp`, `StorageReplicatedMergeTree.cpp`: keep the PR's rollback with `run_sanity_checks = false`, adapted to `StorageInMemoryMetadata::getSettingsChanges`.
`master` is now `26.12`, and `26.11` has already been released without this setting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged the latest
The changed translation units compile without warnings. I could not link and run the tests locally because the build host was overloaded, so CI will run them. @groeneai, thanks for following up on the 02369 |
Conflicts in `StorageMergeTree` and `StorageReplicatedMergeTree`: both sides changed how a mutation entry is created. Kept the mutation `author` and the alter lock from this branch together with `resolvePartitionIdsOfScopedCommands` from master, and adopted the name `startMutation` from master instead of `registerMutation`. In `StorageReplicatedMergeTree::mutate` the partitions are resolved before the alter lock is taken, so user SQL in a partition expression is not evaluated under the lock. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged the latest
Built locally; the nine tests of this PR plus |
| *buf >> "\n"; | ||
|
|
||
| if (buf->eof()) | ||
| if (checkString("tid: ", *buf)) |
There was a problem hiding this comment.
[Blocker] Reject a partially read transaction marker instead of treating it as absent
checkString consumes the matching prefix even when it returns false (src/IO/ReadHelpers.cpp:166). If an existing mutation file is truncated immediately after tid: (without the following space/value), this call consumes the entire suffix and returns false. The constructor then assigns Tx::NonTransactionalTID / Tx::NonTransactionalCSN, skips the loop at EOF, and passes assertEOF. The old reader rejected this file.
This changes recovery semantics: StorageMergeTree::loadMutations skips its transaction-commit check for the resulting entry, so an uncommitted mutation can be replayed as an ordinary mutation after restart. This also affects version-1 files with persist_mutation_author disabled. Use a discriminator that throws once a marker has started, such as checkStringByFirstCharacterAndAssertTheRest, and apply the same strict handling to the trailer markers. Please cover partial transaction markers with a focused loader regression.
Adds an
authorcolumn to thesystem.mutationstable. It records the user who initiated each mutation, which is useful for auditing — for example, finding out who started a long-running or problematic mutation.The author is taken from the user that issued the
ALTER TABLE ... UPDATE/DELETEquery (initial_user, falling back tocurrent_user), and is persisted alongside the mutation entry: in the on-disk entry forMergeTreeand in the ClickHouse Keeper entry forReplicatedMergeTree.Persisting the author is gated behind a new
MergeTreesettingpersist_mutation_author(defaultfalse). When it is disabled, the serialized mutation entry stays byte-for-byte identical to the current format, so mixed-version clusters and downgrades are unaffected. When it is enabled, the entry is written withformat version: 2carrying theauthorfield, so servers that do not know this format fail with an explicitUNKNOWN_FORMAT_VERSIONerror instead of a confusing parse failure. Reading is backward compatible — entries of both versions are parsed correctly, and the column is empty for mutations created without the setting.For
ALTER ... ON CLUSTER, the recorded author is the user executing the query on each host; the initiating user is recorded only when thedistributed_ddl_use_initial_user_and_rolesserver setting is enabled. This is documented in thesystem.mutationsdocs.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added an
authorcolumn to thesystem.mutationstable, showing the user who initiated each mutation. It is populated for mutations created while the newMergeTreesettingpersist_mutation_authoris enabled (disabled by default, because persisting the author extends the mutation entry format that older servers cannot read).Workflow [PR]
Sync PR [sync-upstream/pr/103395]