Repository navigation
Simplified partition mutations - #123506
alexey-milovidov wants to merge 152 commits into
Conversation
`getIncompleteMutationsStatusUnlocked` validated the `current -> intermediate` and `intermediate -> earlier` wait edges independently, so it reported `Deadlock detected` when they went through different partitions. A mutation processes each part independently, so the intermediate mutation can finish its work in the partitions where the current mutation waits for it without waiting for the transaction to commit its work in other partitions: there is no cycle. Now the `intermediate -> earlier` edge is checked only in the partitions where the current mutation waits for the intermediate one. The new test reproduces the reported case: a transaction updates partition 1, a global non-transactional mutation is enqueued with merges stopped, and the transaction then updates partition 2. It used to fail with `Deadlock detected`, and now the statement and the commit succeed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… mutations `markFinishedMutations` and `getUnfinishedMutationCommandsUnlocked` checked each retained mutation by walking the sorted part versions below the mutation version until a part of an affected partition was found. After an `IN PARTITION` mutation finishes, that prefix consists of parts of unrelated partitions, so the pass cost O(parts x retained mutations) under `currently_processing_in_background_mutex`. Compute the minimum data version over all parts and per original partition once, and check each mutation against these aggregates: an unscoped mutation uses the global minimum, a partition-scoped one the minima of its partitions. Patch parts are still attributed to the partition of the data they patch, and the transaction rules in `markFinishedMutations` are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123506&sha=f71f6562db41fe3579ad73696dd1749811e7c329&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.
The |
|
The run you linked was created at 2026-10-28 00:23Z, about 14.5 hours before #127925 was merged (14:53Z). A PR workflow tests the merge commit made when the run was created, and re-run attempts reuse it, so that tree does not contain the fix.
Plain |
… and `getMutationsStatus` After a partition-scoped mutation finishes, parts of other partitions keep data versions below it, so finding the first affecting mutation for each part scanned all retained scoped entries, and each scoped entry in the status scanned the parts of all partitions. Build per-partition lookups once per pass instead: global mutation versions separately from the scoped ones grouped by partition, and the positions of the parts of each partition. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The |
…e legacy mutations are pending `changesTypeOfPartitionKeyColumns` treated every unequal type as a change that can make an `IN PARTITION <value>` literal of a legacy mutation entry undecodable, so adding a member to a partition key `Enum` was refused with `ALTER_OF_COLUMN_IS_FORBIDDEN` while such an entry was pending. Adding members keeps the width, the existing name to value mapping, and therefore both the decoding of the literals and the partition ids. Count only changes which do not preserve all of that (a renamed member still counts), in both `checkAlterEligibility` and the repeated check in `StorageReplicatedMergeTree::alter`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…LTER` Partition-scoped (`IN PARTITION`) mutations can finish out of order, so the completion of the newest mutation no longer implies that the earlier ones are done. `StorageMergeTree::alter` implemented the `RENAME COLUMN` barrier by waiting only for `current_mutations_by_version.rbegin()`: a newer mutation of an empty partition let the rename publish its metadata while an older mutation was still pending in another partition, and the values of the renamed column were lost when that mutation ran. Wait for every unfinished mutation instead, and add a regression test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…name_column_barrier` Fixes the style check: unbounded `while true` loops are not allowed in tests. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123506&sha=519ae2fba0c3d8bfd5b9ddc2618973e374863bc4&name_0=PR&name_1=Style%20check #123506 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/MergeTree/MergeTreeMutationEntry.cpp # src/Storages/MergeTree/MergeTreeMutationEntry.h
… in `selectPartsToMutate` Master added a check of `isDropOrRename` that dereferences `single_mutation_commands`, which this PR changed from a pointer to a `MutationCommands` value. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/MergeTree/MergeTreeData.h # src/Storages/MergeTree/MergeTreeMutationEntry.h
…artition-mutations `master` got its own resolution of the partition scope of mutation commands (#118500): `MutationCommand::has_partition`, `MutationCommand::partition_ids`, `MergeTreeData::resolvePartitionIdsOfScopedCommands` and `MutationsSnapshotBase::filterCommandsOutsidePartition`. It overlaps with what this branch did with `MutationCommand::resolved_partition_ids` and `rewritePartitionScopeToIds`, so the two are unified instead of being kept side by side: - `MutationCommand::resolved_partition_ids` is removed, `MutationCommand::partition_ids` of `master` is the only per-command scope. `MutationsInterpreter`, `MutateTask` and `AlterConversions` take the `master` side. - `rewritePartitionScopeToIds` now calls `resolvePartitionIdsOfScopedCommands` and only computes the scope of the entry as a whole (the union of the partitions of its commands). Where its result is not used (`StorageReplicatedMergeTree::mutate` and `alter`), `resolvePartitionIdsOfScopedCommands` is called directly, once. - `addSupportedCommands` is back to the signature of `master`: the commands of other partitions are dropped by `filterCommandsOutsidePartition`. A scoped command whose partitions are not resolved is therefore not applied on the fly, as on `master`. - `pinPartitionScopeOfLegacyCommands` fills `MutationCommand::partition_ids`. It already covers the commands in the `IN PARTITION ID` form, so the separate `resolvePartitionIdsOfScopedCommands(..., only_pinned)` calls of `master` in `ReplicatedMergeTreeQueue::updateMutations` and `StorageMergeTree::loadMutations` are dropped (the constructor of `MergeTreeMutationEntry` does it for `StorageMergeTree`). Co-Authored-By: Claude Fable 5.2 <[email protected]>
The `arm_tidy` builds failed with `modernize-use-nodiscard`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123506&sha=0dd7c26dde50a923ce92d0368c9762175feffadb&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 #123506 Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged the latest
The The
The review thread about |
The `arm_tidy` build failed with `modernize-use-nodiscard` on this function: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123506&sha=ffb8c54c7ff1892f70809cc5492fd34d9dc01102&name_0=PR&name_1=Build%20%28arm_tidy%2C%202%2F4%29 #123506 Co-Authored-By: Claude Fable 5.2 <[email protected]>
| if (const auto * old_low_cardinality = typeid_cast<const DataTypeLowCardinality *>(&old_type)) | ||
| { | ||
| const auto * new_low_cardinality = typeid_cast<const DataTypeLowCardinality *>(&new_type); | ||
| return new_low_cardinality |
There was a problem hiding this comment.
[Major] Preserve safe LowCardinality wrapper changes while legacy mutations are pending
This requires both types to have the wrapper, so LowCardinality(String) -> String returns false; the reverse conversion falls through to false as well. Both changes are explicitly allowed by isSafeForKeyConversion, and convertFieldToType unwraps LowCardinality, so the existing partition literals and partition IDs remain valid.
For example, take the legacy multi-partition fixture from 05220, use p LowCardinality(String) with pending IN PARTITION 'a', 'b' commands, and issue ALTER TABLE t MODIFY COLUMN p String. The new guard rejects this previously supported conversion with ALTER_OF_COLUMN_IS_FORBIDDEN, requiring an otherwise valid mutation to finish or be killed first.
Please compare the effective partition value types when adding/removing LowCardinality, while retaining the enum name/value checks, and cover both wrapper directions in the legacy-scope regression test.
IN PARTITIONmutations of theMergeTreefamily now track the set of partitions they affect, so parts of unaffected partitions are left intact (their names and files are not changed). This is especially useful for backups and for remote disks.This supersedes #48941 by @ilejn (the original commits and authorship are preserved). The branch of the original PR is in the author's fork, and the latest merge of
master(which touches.github/workflows) could not be pushed there by the automation, so the work continues here. The review history is in the original PR.On top of the original PR, this branch merges the latest
master(one conflict inAlterConversions.cpp, wheremasterstarted carryingmutation_versionincreateLightweightDeleteCommandnext to this PR'sresolved_partition_ids; both are kept), and fixes the Fast test failure of the last run:getMutationsWithLegacyPartitionScoperefreshes/mutationsfrom ZooKeeper without setting a ZooKeeper component, so every partition key type change of aReplicatedMergeTreetable threw aLOGICAL_ERRORexception.The per-command partition scope is shared with #118500, which landed in
masterin the meantime: the scope of a command is resolved once intoMutationCommand::partition_idsbyresolvePartitionIdsOfScopedCommandsand pinned into the command text asIN PARTITION ID. On top of that, this PR tracks the scope of a mutation entry as a whole (the union of the partitions of its commands), and pins the scope of legacy entries.Related: #48941
Related: #118500
Related: #41344
Related: #21326
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improved
IN PARTITIONmutations in theMergeTreefamily to leave unaffected partitions intact. Especially useful for backups and for remote disks.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123506]