Skip to content

Fix skip-index checksums lost in MutateAllPartColumnsTask - #109616

Merged
Avogar merged 30 commits into
ClickHouse:masterfrom
groeneai:fix-109595-skip-index-checksums-mutate-all-columns
Jul 30, 2026
Merged

Avogar merged 30 commits into
ClickHouse:masterfrom
groeneai:fix-109595-skip-index-checksums-mutate-all-columns

Conversation

@groeneai

@groeneai groeneai commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix skip indices being dropped from a data part (or CHECK TABLE failing with UNEXPECTED_FILE_IN_DATA_PART) after a full-part-rewrite mutation, such as ALTER TABLE ... DROP COLUMN of a MATERIALIZED column, on a Wide part.

Description

Closes: #109595

A mutation that rewrites a Wide part through MutateAllPartColumnsTask (for example DROP COLUMN of a MATERIALIZED column) hardlinks the skip-index files that are not being recalculated into the new part, but their checksums were no longer written into the new part's checksums.txt.

Regression from 70a1315cd92 ("remove support of writing statistics in old format", first released in 26.3): it removed MutationContext::existing_indices_stats_checksums, which carried the hardlinked index files' checksums into finalizePart, while leaving the hardlink loop in MutateAllPartColumnsTask::prepare in place. Since then finalize calls finalizePart(..., all_gathered_data) whose checksums is assembled solely from writer output plus projections, so the hardlinked skp_idx_* entries are missing.

  • 26.4/26.5: the index is silently lost (secondary_indices_compressed_bytes -> 0).
  • 26.6/master: the index files are present on disk but not in checksums.txt, so CHECK TABLE fails with UNEXPECTED_FILE_IN_DATA_PART.

Compact parts are unaffected because need_recalculate forces an index rebuild there.

Primary fix: in the hardlink branch of MutateAllPartColumnsTask::prepare, add each preserved index file's source checksum to all_gathered_data.checksums so it reaches finalizePart.

The following related defects were found and fixed while reviewing this change:

  • Long and case-insensitive index filenames. The preserve loop matched checksums.files by the raw skp_idx_<name> prefix, so a substream stored under its hash by replace_long_file_name_to_hash was never reached. Resolution now goes per substream through IMergeTreeDataPart::getStreamNameOrHash.
  • Legacy minmax format. getDeserializedFormat reports only the preferred read layout, so a part carrying both the v1 .idx and the v2 .idx2 payload had one of them omitted. Added IMergeTreeIndex::getAllSubstreamsInPart, which answers what is physically present rather than what is preferred for reading, and moved the mutation and size-accounting callers onto it.
  • Parts already corrupted by the released bug (skp_idx_* on disk, entries missing from checksums.txt) were not repairable: the full-rewrite path dropped the surviving files, and the some-columns and DROP INDEX paths hardlinked them forward unchanged. Such an index is now rebuilt on a full rewrite, and removed on the other two paths, leaving the part consistent either way.
  • Multi-stream indices. A text index owns .dct, .pst and, with phrase search enabled, .pos substreams; the cleanup enumerated only the base .idx/.idx2 plus one mark, so the side streams leaked.
  • Index name collisions. With escape_index_filenames = 0 a stream name is the index name verbatim, so DROP INDEX a addressed skp_idx_a.pos.*, the on-disk name of a surviving index named a.pos, and the reverse direction reached the .pos substream of a text index named a. Ownership is now taken from each surviving index's own getSubstreams and only for the extension that substream declares, so neither direction deletes a file it does not own. The same collision also worked in reverse: a file belonging to another index made a corrupted index look intact, so neither repair path ran, and inside a packed skip-index archive a surviving index that is never packed protected a dropped index's mark. An index's health is now decided only by files no other index declares, and a mark inside a packed archive is protected only when the surviving index is itself packed.

Regression tests: 04401-04404, 04425-04429, 04431.

Deliberately out of scope: with escape_index_filenames = 0, two skip indices can resolve to the
same on-disk filename at WRITE time - for instance a text index a and an index named a.pos,
where the sibling's substream extension is also .idx. The part is then already inconsistent
before any mutation runs, and with a set sibling OPTIMIZE aborts in
MergedPartOffsets. That is a pre-existing defect reproducible on master without any change from
this pull request, it needs a fix at DDL or write time rather than in mutation bookkeeping, and it
is tracked separately.

Version info

  • Merged into: 26.8.1.446 (included in 26.8 and later)

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Wide-part MergeTree with skip indices + a MATERIALIZED column; ALTER TABLE t DROP COLUMN m (mutations_sync=2) then CHECK TABLE t SETTINGS check_query_single_value_result=0 fails every time with UNEXPECTED_FILE_IN_DATA_PART (skp_idx_mm_k.cmrk2).
b Root cause explained? MutateAllPartColumnsTask::prepare() hardlinks non-recalculated skip-index files into the new part (entries_to_hardlink) but their checksums were never added to all_gathered_data.checksums. finalize() calls finalizePart(..., all_gathered_data) whose checksums is assembled only from writer output + projections, so the hardlinked entries are missing from checksums.txt. Regression from 70a1315, which removed existing_indices_stats_checksums (which fed these checksums into finalize) while keeping the hardlink loop.
c Fix matches root cause? Yes. Adds each preserved index file's source checksum to all_gathered_data.checksums in the hardlink branch, restoring the pre-regression behavior.
d Test intent preserved / new tests added? New regression test 04401 added: asserts index present + CHECK TABLE passes after DROP COLUMN on a Wide part. No existing test weakened.
e Demonstrated both directions? Yes. CHECK TABLE fails on master HEAD (build fe094f46), passes with the fix (build e195c586).
f Fix is general, not a narrow patch? Verified across minmax, bloom_filter, set, ngrambf_v1 indices + a projection. The fix operates on the generic hardlink loop, so it covers all skip-index types uniformly. Compact parts confirmed unaffected (need_recalculate rebuilds there).
g Generalizes across inputs (types/params)? Yes. The checksum carry is per source-checksum file entry, independent of index type or column type. Tested with multiple index types over UInt64/String columns.
h Backward compatible? Yes. No format/setting/wire change; only restores checksums.txt content to what pre-26.3 versions wrote. No downgrade concern.
i Invariants and contracts preserved? Yes. all_gathered_data.checksums is only seeded (never before touched in the All-columns path) prior to finalizePart; the writer's fillChecksums adds its own entries on top; the block-structure and part-checksum invariants that CHECK TABLE enforces now hold.

Session id: cron:clickhouse-worker-slot-3:20260707-093400

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

cc @Michicosun @CurtizJ for review (mutations / MergeTree part write). Fixes a data-integrity regression where a full-part-rewrite mutation drops hardlinked skip-index checksums from checksums.txt.

@PedroTadim PedroTadim Jul 7, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@groeneai add another select query after this statement

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 3dfc278 (on the current head): after the CHECK TABLE there is now an EXPLAIN indexes = 1 assertion that the preserved index still prunes granules, plus a data SELECT:

SELECT count() > 0 FROM (EXPLAIN indexes = 1 SELECT count() FROM t_skip_idx_checksums WHERE k = 42) WHERE explain ILIKE '%mm_k%';
SELECT count() FROM t_skip_idx_checksums WHERE k = 42;

Same pair follows the CHECK TABLE for the long-named-index case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The current EXPLAIN checks in tests/queries/0_stateless/04401_mutate_all_columns_preserve_skip_index_checksums.sql and tests/queries/0_stateless/04401_mutate_all_columns_preserve_skip_index_checksums.sql only assert that the index name appears somewhere in EXPLAIN indexes = 1. They still pass on Granules: 20/20, so they do not prove the preserved index is actually pruning after the mutation.

If you want this thread closed on the current head, the assertion needs to match a reduced granule count (as the later legacy-format tests already do), not just the presence of the index name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in ca9c8cc. Both EXPLAIN checks now assert Granules: 1/20 instead of index-name presence. The minmax is on the monotonic non-primary-key column v with index_granularity = 100 (20 granules), so only the skip index can eliminate granules; the assertion returns 0 on 20/20. Verified WITHOUT the fix the preserved-index checks now fail (index shows 20/20), WITH the fix they pass (1/20).

@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [357601d]

Summary: ✅


AI Review

Summary

This PR fixes a real family of skip-index corruption bugs around mutation rewrites and adds good targeted coverage, but two suffix-collision cases are still wrong on the current head. In both cases the new legacy .idx handling for minmax trusts filename presence without enough ownership information, so a text index substream can be mistaken for a minmax legacy file. That can either break a surviving text index during a rebuild mutation or leave part of a dropped text index behind.

Findings

❌ Blockers

  • [src/Storages/MergeTree/MergeTreeIndexMinMax.cpp:282] MergeTreeIndexMinMax::getAllSubstreamsInPart now treats any colliding skp_idx_<name>.idx as the minmax's legacy payload. With escape_index_filenames = 0, a healthy text index a plus minmax a.pst makes this helper report both .idx2 and the text .pst.idx for a.pst. Downstream, a rebuild of a.pst (ALTER TABLE ... UPDATE w = w + 1 WHERE 1) makes collectFilesToSkip / remove_per_substream_checksums drop the surviving text .pst.idx, and calculateSecondaryIndicesSizesOnDisk overcounts a.pst by attributing that text payload to the minmax index.
    Suggested fix: keep the "union of physical minmax layouts" behavior only for files that are actually attributable to the minmax index; do not surface a raw .idx match that is declared by another index.
  • [src/Storages/MergeTree/MutateTask.cpp:1226] collectFilesForRenames has the same ownership gap on the DROP INDEX path. For a healthy text index a and surviving minmax a.pst, protect(".idx") claims the text substream skp_idx_a.pst.idx as owned by the minmax survivor, so DROP INDEX a skips deleting it. The new part therefore retains one substream of the dropped text index in both the filesystem and checksums.txt.
    Suggested fix: only protect the legacy .idx when it is uniquely attributable to the surviving minmax index, or compare against pre-drop declarations so a dropped sibling's text substream cannot be "owned" by the survivor.
Tests
  • ⚠️ Add one focused healthy-table regression with escape_index_filenames = 0, a text index a, and a minmax index a.pst that proves ALTER TABLE ... UPDATE w = w + 1 WHERE 1 leaves the text index usable and keeps all of its substreams.
  • ⚠️ Add the same suffix-collision shape for plain DROP INDEX a and assert that skp_idx_a.pst.idx disappears from the new part.
Final Verdict

Changes required.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 7, 2026
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Done in 3dfc278. Added two queries after the CHECK TABLE: an EXPLAIN indexes = 1 assertion that the preserved mm_k minmax index still prunes granules for k = 42, and the matching SELECT count(). This confirms the hardlinked index is not just present in checksums.txt but functional after the mutation.

Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Good catch, confirmed and fixed in 353bd9e.

The preserved-index hardlink loop scanned source_part->checksums.files by the raw skp_idx_<name> prefix, so with replace_long_file_name_to_hash (long or case-insensitive stream names) the substream stored under sipHash128String(stream_name) was never reached: the hashed .idx/.mrk files were neither hardlinked nor checksummed, and a long-named index was silently dropped by a full-part rewrite.

It now resolves each substream's exact data/mark filename via IMergeTreeDataPart::getStreamNameOrHash, the same way the other mutation paths do, and iterates index->getSubstreams() so text-index side streams are covered too.

Verified with a long-named minmax index (name > max_file_name_length, replace_long_file_name_to_hash=1): before the change secondary_indices_compressed_bytes is 0 after DROP COLUMN (index lost); after it is > 0, CHECK TABLE passes, and the index still prunes. Added that case to 04401_mutate_all_columns_preserve_skip_index_checksums (30/30 passes under randomization).

Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 353bd9e

Every failure below has an owner. Fast test (incl. arm_darwin, our test 04401) and all AST fuzzer jobs re-ran GREEN on this head; the earlier failures were on the superseded commit 3dfc2789 and are not present on 353bd9e.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log (DatabasePostgreSQL::getTablesIterator Code 614, 192.0.2.1:5432) infra (04210 fixture leftover DatabasePostgreSQL engine, TEST-NET-1 unreachable; not PR-caused, this PR only touches MutateTask/skip-index) #109350 (ours, open)
Mergeable Check / PR aggregator (reflects the Upgrade check above only) same as above

Session id: cron:our-pr-ci-monitor:20260707-183000

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 353bd9e

CI fully finished (Finish Workflow pass). One red check; every failure has an owner.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) — "Error message in clickhouse-server.log" infra/known: leftover DatabasePostgreSQL engine probes the unreachable 04210 fixture host 192.0.2.1:5432 during post-upgrade getTablesIterator / AsyncLoader::worker, logging Code: 614 ... Connection to '192.0.2.1:5432' failed — not a regression in this PR #109350 (ours, open)
CH Inc sync — CH Inc sync (private, not actionable by us)

The Upgrade-check error-log scanner flags a pre-existing DatabasePostgreSQL background-connection error unrelated to this skip-index-checksum fix; our PR #109350 allowlists exactly these two code-path signatures (DatabasePostgreSQL::getTablesIterator and AsyncLoader::worker Code 614 to the 192.0.2.1 fixture host).

Session id: cron:our-pr-ci-monitor:20260707-190000

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up commit 078e918 (backward-compat gap flagged by the bot CR on the minmax index).

Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On a debug build: create a minmax-indexed Wide part, DETACH, rename skp_idx_mm_v.idx2 to .idx (v1 layout), drop checksums.txt, ATTACH, then ALTER TABLE ... DROP COLUMN <materialized> (full-part rewrite). Without the fix the .idx data file is gone and pruning falls back to Granules: 20/20; with the fix it stays 1/20.
b Root cause explained? The hardlink loop enumerated the index's substreams via the writer's current getSubstreams(). Minmax reports only .idx2 (v2). An upgraded part still carrying a legacy skp_idx_<name>.idx (v1) therefore never matched the .idx2 probe: the mark file was hardlinked but the .idx data file was not, so the full rewrite silently dropped the index (CHECK TABLE still passed because the orphan mark got checksummed).
c Fix matches root cause? Yes. Enumerate the substreams actually present in the SOURCE part via getDeserializedFormat(source_part->checksums, ...), which probes both .idx and .idx2 and returns the extensions actually on disk. Mirrors loadIndexMarksToCache / removeIndexMarksFromCache / the DROP-INDEX size path.
d Test intent preserved / new tests added? New test 04402_mutate_all_columns_preserve_legacy_idx_minmax.sh covers the legacy .idx case; the existing 04401 (current-format .idx2 + long-hashed) is unchanged and still passes.
e Both directions demonstrated? Yes. Same debug binary, A/B via patch file: baseline → index lost (20/20, .idx gone); fix → index preserved (1/20). Runner: 04401+04402 both 10/10 OK under randomized settings.
f Fix is general across code paths? Yes. getDeserializedFormat is the format-resolution API already used by every other read/size path (mark cache load/remove, DROP-INDEX sizing, MergeTask). This aligns the hardlink loop with them, and covers text-index side streams (.dct/.pst) which getSubstreams() and the source-format both enumerate.
g Fix generalizes across inputs? Yes for the format axis: .idx (v1) and .idx2 (v2) minmax, plus set / bloom_filter / text indices (all use the base or overridden getDeserializedFormat). Hashed long names still resolved via getStreamNameOrHash.
h Backward compatible? Yes — this IS the backward-compat fix: it restores index preservation for pre-format-change (.idx) parts on a full rewrite. No format, setting, or default change.
i Invariants and contracts preserved? Yes. getDeserializedFormat returns only substreams present in the source checksums, so checksums.files.at(file_name) in carry() is guaranteed to exist; the new part's checksums stay consistent with the hardlinked files (CHECK TABLE passes).

Session id: cron:clickhouse-worker-slot-5:20260707-184200

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed the `Fast test (arm_darwin)` failure on 04402 (commit 3801a41).

The test does local-disk part-file surgery (renames the on-disk minmax index file in the detached part dir). The Fast test macOS environment does not reliably expose that layout, so `mv` wrote to stderr and failed the check. Tagged the test `no-fasttest`, matching the convention of other fixture-surgery tests (e.g. 02864_restore_table_with_broken_part). The bug is disk-layer independent and stays fully covered by the sanitizer stateless jobs (amd_asan_ubsan, amd_msan), which pass.

Verified locally: normal stateless mode runs OK (fix validated), fast-tests-only mode SKIPs.

Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Confirmed and fixed in e5d6795.

The packed-archive preservation loop (preserved_skip_index_archive_file_names, and the sibling index_is_in_archive archive_dirty check just above it) enumerated each surviving index's substreams via getSubstreams(), which reports only the current writer layout (.idx2 for minmax). So an upgraded part carrying a legacy skp_idx_<name>.idx member inside skp_idx.packed had its data member dropped when a mutation rebuilt the archive: the loop preloaded the mark member but never the legacy .idx data member, silently losing the index while CHECK TABLE still passed.

Both sites now probe the substreams actually present in the source part via getDeserializedFormat(source_part->checksums, getFileName(), &source_part->getDataPartStorage()), which returns both .idx (v1) and .idx2 (v2) — the same treatment applied to the per-file hardlink loop in 078e918.

Regression test 04403_mutate_preserve_legacy_idx_packed_minmax.sh: builds a part with two packed minmax indices, DETACHes it, rewrites the skp_idx.packed footer to rename skp_idx_mm_v.idx2 -> skp_idx_mm_v.idx (v1/v2 payloads are byte-identical for a non-nullable column), ATTACHes, then ALTER UPDATEs only w (recomputes mm_w, rebuilds the archive) while mm_v is preserved. Asserts mm_v still prunes 1/20 after the rewrite.

A/B (debug, same-binary via patch file, MergeTree over local disk):

  • without fix: rebuilt archive has skp_idx_mm_v.cmrk2 but no skp_idx_mm_v.idx -> mm_v prunes 20/20 (LOST), CHECK TABLE still passes.
  • with fix: rebuilt archive preserves skp_idx_mm_v.idx -> mm_v prunes 1/20, mm_w recomputed to .idx2, CHECK TABLE passes.
  • 04403 runner: 5/5 OK with fix, FAILs on baseline; existing 04402 still 3/3 OK (no regression).

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 04403_mutate_preserve_legacy_idx_packed_minmax.sh fabricates a legacy .idx minmax member inside skp_idx.packed, then ALTER UPDATE w rebuilds the archive. On the baseline binary it fails deterministically (after: 0, index lost) every run.
b Root cause explained? The packed-archive preserve loop and its index_is_in_archive archive_dirty check enumerated index_ptr->getSubstreams(), which reports only the current writer layout (.idx2). A legacy skp_idx_<name>.idx member inside skp_idx.packed is therefore never matched, so it is not pre-loaded into the rebuilt archive -> the data member is dropped while the mark member survives -> the index no longer prunes; CHECK TABLE passes because the old archive checksum is removed and re-added.
c Fix matches root cause? Yes. Both sites now enumerate getDeserializedFormat(source_part->checksums, getFileName(), &source_part->getDataPartStorage()), which probes the source checksums for both .idx (v1) and .idx2 (v2). Same mechanism as the per-file hardlink fix (078e918).
d Test intent preserved / new tests added? New regression 04403 added; existing 04402 (per-file path) unchanged and still passes.
e Both directions demonstrated? Yes. Baseline: after: 0 (LOST), test FAILs. With fix: after: 1, 5/5 OK. Same debug binary swapped via patch file.
f Fix is general across code paths? Yes. Both packed-archive sites in this function are fixed (detection index_is_in_archive + preserve loop), matching the already-fixed per-file hardlink loop and the DROP-INDEX / remove_per_substream_checksums paths. No remaining getSubstreams()-based source-part enumeration in the preserve/detect paths.
g Fix generalizes across inputs? getDeserializedFormat is the generic version-probe used across all index types (minmax .idx2/.idx, base .idx, text-index side streams). It returns whatever substreams the source part actually has, so the fix covers every index whose on-disk format may lag the writer, not just minmax.
h Backward compatible? Yes — this is a backward-compat fix: it makes a full-part rewrite preserve legacy-format packed index members instead of dropping them. No setting/format change; no SettingsChangesHistory impact.
i Invariants and contracts preserved? Yes. The rebuilt skp_idx.packed now contains every surviving member's data + mark (checksums stay consistent, CHECK TABLE passes and the index prunes). Recomputed indices are still written fresh by the writer; only genuinely-preserved members are pre-loaded, so no double-write.

Session id: cron:clickhouse-worker-slot-1:20260707-230500

@zlareb1
zlareb1 requested a review from Avogar July 8, 2026 06:53
@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto master (resolved the conflict in MutateTask.cpp with #108853, which landed the packed-skip-index write/mutate dedup while this PR was open).

Merge notes:

  • Packed skip indices: consolidate access and hide internals #108853 centralized the archive-membership probe into IMergeTreeDataPart::isSkipIndexInPackedArchive(), superseding this PR's inline index_is_in_archive lambda in updateIndicesToRecalculateAndDrop. To keep the legacy-format fix DRY and cover both call sites, the getSubstreams() -> getDeserializedFormat(checksums, ...) change now lives inside that shared method instead of the lambda. The per-file hardlink loop and the packed-archive preserve loop keep their getDeserializedFormat treatment.
  • Packed skip indices: consolidate access and hide internals #108853 also bumped the packed archive to v1 (per-entry uncompressed_size), so the footer-rewrite helper in 04403_mutate_preserve_legacy_idx_packed_minmax.sh was made version-aware (carries the extra per-entry u64 through).

Re-validated on the merged tree (same-binary A/B): master baseline drops the legacy minmax member (04402 UNEXPECTED_FILE_IN_DATA_PART, 04403 after:0), the fix preserves it (04401/04402/04403 pass; 20x randomized OK).

Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the rebuild-path gap in commit f386b3e.

collectFilesToSkip (MutateTask.cpp ~1026) and remove_per_substream_checksums (~2571) enumerated index->getSubstreams() (minmax reports only .idx2), so on an upgraded part still carrying a legacy skp_idx_<name>.idx, a rebuild mutation (ALTER UPDATE of the indexed column, MATERIALIZE INDEX) wrote a fresh .idx2 but the old .idx was neither added to the skip list nor stripped from the inherited checksums. It got hardlinked into the new part and leaked dead next to the fresh .idx2, with a stale checksum entry. Both helpers now enumerate the substreams actually present in the source part via getDeserializedFormat(source_part->checksums, index->getFileName(), &source_part->getDataPartStorage()), matching the preserve loop and the packed-archive loop; getStreamNameOrHash still resolves hashed long names.

Regression: 04404_mutate_rebuild_legacy_idx_minmax.sh fabricates a legacy .idx part, runs ALTER UPDATE v = v (recomputes mm_v), and asserts the new active part has .idx2 and NOT the leaked .idx, plus CHECK TABLE and pruning. Verified both directions on a debug build via same-binary A/B: baseline leaks the .idx (legacy_idx_leaked: 1, test FAILs); with the fix legacy_idx_leaked: 0 and it passes. 60/60 across 04404/04402/04403 under randomization.

@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 04404_mutate_rebuild_legacy_idx_minmax.sh: fabricate a legacy .idx minmax part, ALTER UPDATE v = v (rebuilds mm_v); baseline leaves both .idx and .idx2 in the new active part (legacy_idx_leaked: 1).
b Root cause explained? collectFilesToSkip and remove_per_substream_checksums enumerated index->getSubstreams(), which for minmax reports only the current .idx2. A legacy .idx on an upgraded part is invisible to it, so on a rebuild mutation it is neither skipped nor removed, and the hardlink loop carries it into the new part with a stale checksum entry.
c Fix matches root cause? Yes. Both helpers now enumerate substreams present in the source part via getDeserializedFormat(source_part->checksums, ...) (probes both .idx v1 and .idx2 v2), identical treatment to the already-fixed preserve and packed-archive loops.
d Test intent preserved / new tests added? New test 04404 covers the rebuild path (companion to 04402 preserve / 04403 packed). Asserts the leaked .idx is absent, .idx2 present, CHECK TABLE passes, pruning 1/20.
e Both directions demonstrated? Yes, same-binary A/B (debug). Baseline (Build ID 4b548ccd): legacy_idx_leaked: 1, test FAILs. With fix (3e88ed29): legacy_idx_leaked: 0, passes.
f Fix is general across code paths? Yes. This completes the getSubstreams()->getDeserializedFormat migration across all four sites in MutateTask.cpp: per-file hardlink (078e918), packed-archive preserve (e5d6795), and now the two rebuild-path helpers collectFilesToSkip + remove_per_substream_checksums.
g Fix generalizes across inputs? Yes. getDeserializedFormat probes both .idx/.idx2 for any index whose on-disk format changed; getStreamNameOrHash covers hashed long/case-insensitive names (replace_long_file_name_to_hash).
h Backward compatible? Yes. Purely restores correct handling of legacy (pre-format-change) parts; no setting, format, or default change.
i Invariants and contracts preserved? Yes. The new part's on-disk files and checksums.txt stay consistent (no leaked file, no stale/missing checksum entry); CHECK TABLE passes on the rewritten part.

Session id: cron:clickhouse-worker-slot-8:20260708-123000

@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 04402 with an added secondary_indices_compressed_bytes > 0 assertion on the repaired part fails deterministically without the fix (size accounting -> 0) and passes with it (-> 1).
b Root cause explained? calculateSecondaryIndicesSizesOnDisk enumerated index_ptr->getSubstreams(), which for minmax reports only .idx2. On a part carrying a preserved legacy skp_idx_<name>.idx, the loop found no checksum entry for .idx2, so it counted only the mark file and reported the data payload as 0 in system.parts.secondary_indices_compressed_bytes.
c Fix matches root cause? Yes. The loop now uses getDeserializedFormat(checksums, index_name, &getDataPartStorage()).substreams, which probes the source checksums for both .idx (v1) and .idx2 (v2), so the actually-present legacy payload is accounted.
d Test intent preserved / new tests added? 04402 extended with a size-accounting assertion; the existing preservation/pruning assertions are unchanged.
e Both directions demonstrated? Yes. Same-binary A/B: without fix (Build ID 3E88ED29) size accounting = 0 FAIL; with fix (Build ID EC2F100A) = 1 PASS.
f Fix is general across code paths? Yes. This is the last of five getSubstreams() sites; the four MutateTask.cpp sites and isSkipIndexInPackedArchive already use getDeserializedFormat. All read/size/mutate paths now probe the present substreams.
g Fix generalizes across inputs? getDeserializedFormat probes both legacy .idx (v1) and current .idx2 (v2) for any index whose on-disk format changed; long/hashed names still resolve via getStreamNameOrHash in the size loop.
h Backward compatible? Yes. Behavior change is strictly additive (accounts an already-on-disk payload previously missed). No setting, format, or metadata change.
i Invariants and contracts preserved? Yes. The loop still sizes each substream via checksums (standalone) or the packed-archive fallback; total and per-index sizes remain consistent; no lock or ownership change.

Session id: cron:clickhouse-worker-slot-7:20260708-134400

Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@Avogar Avogar self-assigned this Jul 8, 2026
@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Fabricate a mixed part (copy skp_idx_mm_v.idx2 to .idx, drop checksums, ATTACH), then ALTER UPDATE v = v. On the pre-fix binary the active part leaks skp_idx_mm_v.idx alongside the fresh .idx2 (rebuild_stale_idx_leaked: 1).
b Root cause explained? getDeserializedFormat() returns one preferred layout (minmax: .idx2 over .idx). The two cleanup lambdas enumerated it, so on a mixed .idx+.idx2 part the stale .idx was neither added to files_to_skip nor stripped from inherited checksums, and got hardlinked into the new part with a stale checksum.
c Fix matches root cause? Yes. New getAllSubstreamsInPart() returns the union of all physical substream versions; the two cleanup lambdas use it so the stale .idx is skipped and stripped. Read paths keep getDeserializedFormat() (they need one layout).
d Test intent preserved / new tests added? New test 04425_mutate_mixed_legacy_idx_minmax.sh covers rebuild and DROP INDEX on a mixed part. Existing 04401/04402/04403/04404 unchanged and still pass.
e Both directions demonstrated? Yes. Same-binary A/B (debug, buildId EC2F100A baseline / 9EB1A7E1 fix): baseline rebuild_stale_idx_leaked: 1, fix 0 and matches the reference.
f Fix is general across code paths? Yes. Both mutation cleanup sites (recalc/drop skip-list + checksum stripper) now use getAllSubstreamsInPart(). The preserve/size-accounting/read paths intentionally keep the single preferred layout (they must deserialize exactly one version, and preserve carries only the readable layout so the stale one dies).
g Fix generalizes across inputs? The union helper is minmax-specific (the only index whose extension changed .idx->.idx2). Base and text indices delegate to getDeserializedFormat() (single, never-changed extension) so no behavior change. Verified across short/long-name via 04402/04404 (existing) and mixed via 04425.
h Backward compatible? Yes. Cleans up dead legacy files on mutation; changes no on-disk/wire format, no setting default, no new validation.
i Invariants and contracts preserved? Yes. New part's index files and checksum entries stay consistent (CHECK TABLE passes). getAllSubstreamsInPart() is read-only over source checksums; read/deserialize paths are untouched, so the single-layout deserialization contract holds.

Session id: cron:clickhouse-worker-slot-7:20260708-151500

@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On 04401's pre-change table (2000 rows, default granularity) the preserved index only ever showed Granules: 1/1, so the old ILIKE '%<index name>%' check would also pass on a non-pruning 20/20 plan. With index_granularity = 100 (20 granules) and the minmax on the monotonic non-PK column v, EXPLAIN indexes = 1 ... WHERE v = 1042 deterministically prunes 20/20 -> 1/20.
b Root cause explained? The two EXPLAIN checks asserted only that the index NAME appeared in the plan; that string is present even when no granules are pruned (Granules: 20/20), so they did not prove the preserved index still prunes after the mutation.
c Fix matches root cause? Yes. The assertion now matches Granules: 1/20, which is only produced when the skip index eliminates granules. v is not the primary key, so only the minmax can prune, isolating the signal to the preserved index.
d Test intent preserved / new tests added? Preserved and strengthened. Both the short-named and long-named (hashed) index cases now prove pruning, not just presence; all other assertions (part_type, secondary_indices_compressed_bytes > 0, CHECK TABLE) are unchanged.
e Demonstrated in both directions? Yes. With the minmax present the assertion returns 1 (1/20); after DROP INDEX (no pruning, 20/20) the same assertion returns 0.
f Fix general, not a narrow patch? N/A (test-assertion-quality change, not a code bug).
g Generalizes across inputs / type wrappers? N/A (test-assertion-quality change).
h Backward compatible? N/A (test-only).
i Invariants / contracts preserved? N/A (test-only).

Verification: 04401 = 20/20 OK under randomization; the 04402/04403/04404/04425 legacy/mixed family = 40/40 OK (no regression). Guarded diff: 2 files (.sql +16/-11-ish, .reference 1 line), no submodule/contrib drift. Pushed 92e98c8..ca9c8cc (fast-forward).

Session id: cron:clickhouse-worker-slot-0:20260708-164600

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — fc4ed57

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
Stateless tests (amd_asan_ubsan, flaky check) / 04428_mutate_corrupted_text_index_multistream (5 runs, then Too many test failures) PR-caused: this is the test this PR adds, and it breaches the 180 s per-test limit on every flaky-check repetition. The only CI sighting of this test in 10 days is on this PR fixed in this PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01666_merge_tree_max_query_limit Code: 202 TOO_MANY_SIMULTANEOUS_QUERIES under parallel replicas; reproducible 3/3 on rerun, not caused by this diff #112385 (mine, open)

Session id: cron:our-pr-ci-monitor:20260729-140000

groeneai added 3 commits July 29, 2026 17:12
`Stateless tests (amd_asan_ubsan, flaky check)` failed 04428 five times out of
five with `Test runs too long (> 180s)`. The cost was client process spawns,
not query work: the test issued 82 sequential ${CLICKHOUSE_CLIENT} calls, and
on this build 82 bare spawns take 4.55s of the test's 5.9s wall clock (55ms
each) while the same 82 statements in one call take 0.17s. Under ASAN on a
loaded flaky-check host running 50 repeats, that constant is what crosses the
limit.

Group the fixture DDL, the mutation and the following assertions into single
calls, and let `make_corrupted_part` and the mutation statements return the
part path they just produced instead of having `orphan_on_disk` and
`side_streams_on_disk` re-query `system.parts` for it. A mutation with
`mutations_sync = 2` completes inside the batch, so a `SELECT path FROM
system.parts` in the same call already observes the post-mutation part.

82 spawns become 24, and the test goes from 5.59-6.14s to 2.69-2.89s. No
assertion, oracle, setting, row count or index count changes: the .reference
file is byte-identical, and reverting each of the three guards under test
(the substream walk, the checksums-membership check and the multi-substream
presence probe) still reddens exactly the paths it did before.
`SELECT count() FROM t_some WHERE hasToken(s, 'hello10')` was meant to show the
surviving text index is still usable, but it proves nothing. The token sits in
all five granules, so the count is 10 whether the index is read or not, and with
an `ngrams` tokenizer `hasToken` does not consult a text index at all: the plan
reports `Granules: 5/5` both with and without `use_skip_indexes`.

Nor can the assertion be repaired into a pruning check. Any query that makes
this table's text index prune opens `skp_idx_a.pos.cmrk2`, which the minmax
index `a.pos` and the text `.pos` substream both write under
`escape_index_filenames` = 0, so `hasPhrase` and a `LIKE` substring both throw
`CANNOT_READ_ALL_DATA` on a pristine part, before any of this test's surgery.
Renaming the sibling to `b` makes the same queries prune `Granules: 1/5`, which
confirms the collision is the cause and is the pre-existing write-time issue
`text_streams_on_disk` already documents.

Assert instead that the index is still registered with readable substream sizes
in `system.data_skipping_indices`, which is what a hardlinked-forward orphan
loses, and record in the comment why a query-level oracle is not available here.
MergeTreeIndexSubstreams substreams;
if (indexFileExistsInChecksums(checksums, relative_path_prefix, ".idx2", storage))
substreams.push_back({MergeTreeIndexSubstream::Type::Regular, "", ".idx2"});
if (indexFileExistsInChecksums(checksums, relative_path_prefix, ".idx", storage))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This still misattributes colliding text substreams as legacy minmax data when escape_index_filenames = 0.

A healthy table with text index a and minmax index a.pst has both skp_idx_a.pst.idx (the text index's .pst data) and skp_idx_a.pst.idx2 (the minmax payload). This helper now reports both as substreams of a.pst, so a rebuild of a.pst (ALTER TABLE ... UPDATE w = w + 1 WHERE 1) makes collectFilesToSkip / remove_per_substream_checksums treat the text .pst.idx as stale minmax state: it is not hardlinked into the new part and its checksum is stripped even though the text index survives. The same false .idx also gets counted into secondary_indices_*_bytes for a.pst.

getAllSubstreamsInPart needs an ownership check here, not a raw "filename exists" union.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Both confirmed by measurement, and I am declining them for this PR on scope rather than on
substance. Follow-up filed; details below.

The fixture is constructible: a text index a plus a minmax index named a.pst under
escape_index_filenames = 0 produces both skp_idx_a.pst.idx (the text .pst payload) and
skp_idx_a.pst.idx2 (the minmax payload). I A/B'd every case against the pristine master
snapshot, whose MergeTreeIndexMinMax.{cpp,h}, MergeTreeIndices.cpp and
IMergeTreeDataPart.cpp are md5-identical to this branch's merge base, so it is a valid control.
Build ids of both binaries verified against readelf -n before every run.

action sibling build skp_idx_a.pst.idx CHECK system.data_skipping_indices
ALTER UPDATE w a.pst this PR DELETED 1 a=150/113442, a.pst=61/72
ALTER UPDATE w a.pst master PRESENT 1 a=211/115783, a.pst=61/72
ALTER UPDATE w b.pst this PR PRESENT 1 a=200/115783, b.pst=61/72
ALTER UPDATE w b.pst master PRESENT 1 a=200/115783, b.pst=61/72
DROP INDEX a a.pst this PR PRESENT 1 a.pst=61/2412
DROP INDEX a a.pst master DELETED 1 a.pst=0/0
DROP INDEX a b.pst this PR DELETED 1 b.pst=61/71
DROP INDEX a b.pst master DELETED 1 b.pst=61/71

Both of your claims reproduce (rows 1 and 5). The two non-colliding b.pst rows are
byte-identical between this branch and master, so neither behaviour touches a table without a
suffix collision.

Two measurements bound how much this matters, and one of them changes the shape of the answer.

First, on a colliding table the text index is unreadable from birth, on unmodified master, with
no mutation and no part surgery: hasPhrase(s, 'alpha beta') returns
Code: 33 CANNOT_READ_ALL_DATA: Too many marks in file skp_idx_a.pst.cmrk2, marks expected 1.
With the sibling renamed b.pst the same fixture answers 500. The cause is at write time, not in
cleanup: minmax a.pst and the text index's .pst substream both write
skp_idx_a.pst.cmrk2. After the rebuild that query throws the same Code 33 on this branch and on
master. So the file dropped in row 1 was never readable, and the user-visible delta is the
reported index size, not query results. CHECK TABLE is 1 in all eight cells.

Second, on your DROP INDEX point, this branch and master fail in opposite directions and this
branch is the better one. EXPLAIN indexes = 1 on the surviving minmax after DROP INDEX a:
this branch keeps Granules: 1/5 with survivor a.pst at 61/1098, master reports Granules: 5/5
with survivor a.pst at 0/0, because master deletes the survivor's own .idx2 and .cmrk2 and
leaves only skp_idx_a.pos.*. Destroying the surviving index is the bug 04429 covers. The
retained file you identified is the price of not destroying it, and I would rather keep one
unreadable file of a dropped index than delete a healthy index the user still has.

On the proposed remedy: an ownership check cannot go where you point it.
getAllSubstreamsInPart(checksums, relative_path_prefix, storage) receives no metadata snapshot
and no sibling list, so ownership is not derivable there. It needs
metadata_snapshot->getSecondaryIndices(), which only the callers have, and this PR already has
that primitive in isIndexResolvableFromOwnFiles. For DROP INDEX it is harder than moving code:
metadata_snapshot in collectFilesForRenames is already post-drop, so the dropped index is
absent and "does the dropped text index declare skp_idx_a.pst.idx" cannot be answered from
metadata at all without threading pre-drop metadata through. That is a change to the
substream-ownership model across seven call sites, with its own fixtures.

I also cannot simply narrow the union walk, which is the other obvious shape: the override exists
for the legitimate mixed-format part where one minmax index carries both a legacy .idx and a
modern .idx2, and 04425 fabricates exactly that and asserts the reported size sums both files.

So I am keeping this PR to the bug it fixes and tracking the ownership model separately. Note that
none of this is reachable at shipped defaults: escape_index_filenames defaults to true, which
escapes the sibling to skp_idx_a%2Epst.*; measured at the default there is no collision and both
indexes answer correctly.

One process note: this is the seventh round on this collision family. Each round has been a
narrower spelling of one seam, which is that the filename namespace is ambiguous under
escape_index_filenames = 0, so ownership cannot be recovered from a filename suffix after the
fact by any number of per-site guards. I do not think another cleanup-side guard is the answer, and
I would rather a maintainer weigh whether colliding index names should be disambiguated or rejected
at write time. I am stopping the automated loop here and leaving that question open.

/// minmax changed `.idx` (v1) -> `.idx2` (v2), so an upgraded part may still carry
/// the legacy file for a substream that now declares `.idx2`.
if (substream.extension == ".idx2")
protect(".idx");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The legacy .idx protection here can still keep part of a dropped text index alive.

With escape_index_filenames = 0, a healthy text index a and a surviving minmax a.pst collide on skp_idx_a.pst.idx (text .pst data vs the minmax legacy probe). protect(".idx") adds that text file to surviving_index_owned_files, so DROP INDEX a skips deleting it and the new part keeps one substream of the dropped index in both the filesystem and checksums.txt.

This needs the same ownership check as the minmax legacy handling above; otherwise DROP INDEX is still incomplete on suffix-collision tables.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed, and answered together with the MergeTreeIndexMinMax.cpp comment in
#109616 (comment) since both are the
same underlying issue.

Short version for this thread: your claim reproduces, but on a colliding table this branch and
master fail in opposite directions and this branch is the better one. Measured with
EXPLAIN indexes = 1 after DROP INDEX a, this branch keeps Granules: 1/5 with the surviving
minmax at 61/1098, while master reports Granules: 5/5 with the survivor at 0/0 because it deletes
the survivor's own .idx2 and .cmrk2. Destroying the surviving index is the bug 04429 covers; the
retained file is the price of not destroying it, and the retained file was never readable anyway
because the collision is at write time (hasPhrase throws Code: 33 CANNOT_READ_ALL_DATA on a
pristine part on unmodified master).

The ownership check cannot go at the site you point to either:
metadata_snapshot in collectFilesForRenames is already post-drop, so the dropped index is absent
and its declared substreams cannot be looked up from metadata at all without threading pre-drop
metadata through. Tracked separately rather than folded in here.

@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.40% 86.40% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.50% 78.50% +0.00%

Changed lines: Changed C/C++ lines covered: 179/182 (98.35%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 357601d

No failures to own on this head. All 174 check-runs are complete: 156 success, 18 skipped, 0 failure, 0 incomplete. Config Workflow, Fast test, Fast test (arm_darwin), Style check, all five flaky-checks, all three Bugfix validation jobs and Finish Workflow are green, and CIDB reports 0 FAIL/ERROR rows across 158 checks and 320840 test rows for this commit.

Check / test Reason Owner / fixing PR
(none) - All checks green

Both reds on the previous head (fc4ed57d6eec) are resolved here:

  • Stateless tests (amd_asan_ubsan, flaky check) / 04428_mutate_corrupted_text_index_multistream was PR-caused, breaching the 180 s per-test limit on every repetition. After batching its setup it now passes 50/50 on the amd_msan, amd_tsan and arm_asan_ubsan flaky-checks and 46/46 on amd_debug, at 32.8 s to 108.1 s average and 112.8 s worst case. The sibling 04431_mutate_corrupted_index_sibling_owns_file also passes 50/50.
  • Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01666_merge_tree_max_query_limit does not recur; its fix Fix 01666_merge_tree_max_query_limit under parallel replicas #112385 is merged.

Session id: cron:our-pr-ci-monitor:20260730-013000

@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 37 queries analysed

This PR fixes on-disk skip-index file cleanup during mutations and DROP INDEX (handling stale legacy substreams and orphaned files); it does not touch the query-execution hot path. One query was flagged on clickbench (Q4) with an apparent -19.6% improvement, but it was correctly left as no change: Q4's plain SELECT does not exercise the mutation-cleanup code this PR changes, and its median (232.0 ms) falls squarely inside master's current variance band of 201-297 ms, so the delta is run-to-run noise rather than a real PR effect. The deterministic suppression here is sound and no directional verdict is warranted.

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 449013d8-f095-4e8d-87ef-62fd0a8a255f
  • MIRAI run: a5de811c-f435-4cce-acc3-7691c9287997
  • PR check IDs:
    • clickbench_985622_1785429899
    • clickbench_985629_1785429898
    • clickbench_985640_1785429898
    • tpch_adapted_1_official_985651_1785429898
    • tpch_adapted_1_official_985666_1785429899
    • tpch_adapted_1_official_985692_1785429898

@Avogar
Avogar added this pull request to the merge queue Jul 30, 2026
Merged via the queue into ClickHouse:master with commit 54e0e9c Jul 30, 2026
180 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 30, 2026
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 31, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 31, 2026
arsenmuk added a commit that referenced this pull request Jul 31, 2026
Reconcile with master: the root-cause skip-index-checksum fix in
MutateAllPartColumnsTask landed via #109616. Keep the source_part storage
discriminators, and add two regression tests not covered by #109616:
- 04416_mutate_all_columns_projection_hardlink (untouched projection hardlinked
  on an all-columns rewrite)
- 04416_mutate_all_columns_packed_prefix_collision (idx_a/idx_a6 prefix collision
  on packed part storage)
@scanhex12 scanhex12 removed the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 31, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 31, 2026
Resolves the semantic overlap with the now-merged ClickHouse#109616, which introduced
IMergeTreeIndex::getAllSubstreamsInPart. That accessor answers the physical
question independently (its own getSubstreams + indexFileExistsInChecksums
walk, with an explicit comment that it is deliberately not routed through
getDeserializedFormat), so it needs no redirection onto this branch's new
getPhysicalFormat: the union-of-on-disk-versions property that mutation
cleanup and size accounting depend on holds by construction after the merge.

The only textual conflict was the MergeTreeIndexMinMax declaration block,
where this branch renames the virtual to getPhysicalFormat and master adds a
getAllSubstreamsInPart override. Both are kept.

Master adds no new getDeserializedFormat call site (13 before, 13 after), so
the usability-versus-physical audit of this branch still covers every caller.
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 pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync 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.

Mutations via MutateAllPartColumnsTask write checksums.txt without hardlinked skip-index files

6 participants