Skip to content

Handle part storage type changes in mutations - #126865

Merged
alexey-milovidov merged 1 commit into
masterfrom
upstream-mutate-task-divergence
Oct 23, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
upstream-mutate-task-divergence

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Make MutateTask handle mutations whose result part has a different part storage type than the source part (e.g. Full vs Packed). Files cannot be reused by hardlinks across storage types, so such a mutation must rewrite the whole part:

  • skip the no-op clone fast path when the storage type changes;
  • pass the future storage type to splitAndModifyMutationCommands, so the per-file rename path is not used;
  • set return_all_columns in the MutationsInterpreter settings and treat the mutation as affecting all columns;
  • rebuild indices and projections instead of hardlinking them (is_per_file_compatible_part_storage);
  • do not copy existing_rows_count from the source part.

Also:

  • add the isPerFilePartStorage helper (storage formats with one addressable object per logical file, which allow per-file hardlink reuse; currently equal to isFullPartStorage) and use it in the places that decide about per-file reuse;
  • add PartMergerWriter::cancel, which drops temporary projection parts of the merge subtasks for shared storages, and call it from the cancel of the mutation tasks;
  • fix a typo in a comment.

In public builds mutations keep the storage type of the source part (future_part->part_format is copied from the source part), so this changes no observable behavior here; the code path is used by downstream forks that choose the storage type of the mutated part anew. The motivation is to reduce divergence with downstream forks, which causes merge conflicts.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

...

🤖 Generated with Claude Code


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

Version info

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

When the future part of a mutation has a different storage type than the
source part (e.g. `Full` vs `Packed`), files cannot be reused by hardlinks,
so the mutation must rewrite the whole part: skip the no-op clone fast path,
make the `MutationsInterpreter` return all columns, treat the mutation as
affecting all columns, rebuild indices and projections, and do not copy
`existing_rows_count` from the source part.

Also add `isPerFilePartStorage` (storage formats that allow per-file
hardlink reuse; currently only `Full`), cleanup of temporary projection
parts in `PartMergerWriter::cancel` for shared storages, and fix a typo in
a comment.

This reduces divergence with downstream forks.

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

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [de0922f]

Summary: ✅


AI Review

Summary

PR #126865 makes MutateTask rewrite the whole part when its storage format changes, rebuild dependent indices and projections, and clean up temporary projection parts on shared-storage cancellation. No actionable correctness or safety findings at de0922fd3d2f1397deb7e9d8ab66d2b3e7e696a5.

Missing context / blind spots
  • ⚠️ Public mutation callers preserve the source storage format, and shared storage is implemented downstream. These added paths were reviewed statically; runtime validation requires downstream migration and cancellation regression results, which were not supplied. No local build or tests were run.
Final Verdict

Status: ✅ Approve. No required changes identified.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). labels Oct 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing de0922fd3 with master f21568802 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 629df3319; 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

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

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

@alexey-milovidov alexey-milovidov self-assigned this Oct 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 23, 2026
Merged via the queue into master with commit faa1f58 Oct 23, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the upstream-mutate-task-divergence branch October 23, 2026 23:42
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 18, 2026
…-only-mutation-space

Conflicts in MutateTask.cpp, ReplicatedMergeTreeQueue.cpp and StorageMergeTree.cpp:
- mutationRequiresFullPartRewrite, which replaced the shape predicate in rewritesAllPartColumns
  and splitAndModifyMutationCommands, now uses isPerFilePartStorage (ClickHouse#126865), and
  splitAndModifyMutationCommands keeps master's future_storage_type condition and
  getColumnNameInStorage.
- processStatisticsChanges takes master's new parameters and rename handling and keeps
  the bool result and the early return for unchanged statistics.
- The !recalculate_ttl_only condition (ClickHouse#125025) moves into requires_full_part_rewrite,
  which rewrites_all_columns reuses.
- The queue keeps both master's source_parts and mutation_source_part.

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

comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). pr-not-for-changelog This PR should not be mentioned in the changelog 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.

2 participants