Repository navigation
Do not remove another column's stream with a column dropped from a merged part - #118246
Conversation
…rged part
A column that no source part holds and that has no default expression is
dropped from the merged part, and its files are looked up through the part's
serialization of that name. Once the column itself is gone from the part, that
name resolves to the serialization of a same-named subcolumn of another column -
a column named like a subcolumn, `a.size0` next to an `Array` column `a` - so
the streams enumerated from it are the *other* column's. The removal then took
the array's offsets file with it, and every read of the table failed:
CREATE TABLE t (a Array(UInt64)) ENGINE = MergeTree ORDER BY tuple()
SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO t VALUES ([10, 20, 30]);
ALTER TABLE t ADD COLUMN `a.size0` UInt64;
OPTIMIZE TABLE t FINAL;
SELECT a FROM t;
Code: 49. Stream a.size0 for column a with type Array(UInt64) is not found.
The removal now takes the serialization from the column entry of the part's
column list, and skips a column the list does not hold at all - such a column
has no files in the part to remove.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [80a88d4] Summary: ✅
AI ReviewSummaryThis PR fixes the merge-side and mutation-side stream-accounting bug behind shadowing names like Tests
Final Verdict
LLVM Coverage ReportMeasured on commit 80a88d4.
Changed lines: Changed C/C++ lines covered: 30/31 (96.77%) · Uncovered code |
|
The fix looks complete for the merge side: both callers of One sibling of the same shape stays open after this PR and #118242: the wide-part |
Build profile diff (arm_release)Commit See the job log for details. |
…column `collectFilesForRenames` resolved the dropped or renamed column name through `IMergeTreeDataPart::tryGetSerialization` and enumerated the resulting streams to decide which files of a wide part to remove or rename. A column the part holds only as a missing-column marker (`skip_empty_columns_on_insert` with `serialization_info_version = 'with_missing_columns'`) has no serialization of its own, so a name like `a.size0` next to an `Array` column `a` resolved to that array's subcolumn serialization: `ALTER TABLE ... DROP COLUMN` then removed the array's offsets stream from the mutated part and every read of the array failed with a `LOGICAL_ERROR` exception. Apply the same rule as `removeEmptyColumnsFromPart` on the merge side: look the serialization up only for a column the source part physically holds, and skip the stream enumeration otherwise. The `RENAME COLUMN` fallback path (for parts without `columns_substreams.txt`) enumerates the streams the same way and is guarded too. Closes: #118255 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Pushed c3a043c: master merged in, plus the mutation-side half of this bug that the review asked for ( @groeneai, the reds on the previous commit look unrelated to this change and need a separate look:
|
|
Tracked, and already fixed on master: #118489 (yours), merged 2026-09-10T14:42:04Z as All 15 CIDB rows for this test in the last 30 days (10 pull requests plus 5 true-master runs) carry the same signature, so that one fix closes the whole class: |
…holds `getStreamCounts` in `MutateTask.cpp` decides which files of the source part a mutation rewrites instead of hardlinking. For a column name that is not recorded in `columns_substreams.txt` it fell back to `tryGetSerialization`, which resolves the name in the part's serializations including the generated subcolumns of other columns. For a column the part does not hold (a missing-column marker written with `skip_empty_columns_on_insert` and `serialization_info_version = 'with_missing_columns'`) named like a subcolumn of another column (`a.size0` next to an `Array` column `a`), that lookup answers with the array's offsets serialization, and the offsets stream would be marked as rewritten and not hardlinked. The same guard the previous commit added to `collectFilesForRenames` is applied here: only a column present in the part's column list has streams to count. The dependent-column paths of `ALTER TABLE ... CLEAR COLUMN` (a recomputed skip index and a recomputed `MATERIALIZED` column) are pinned by the new test `05227_mutation_clears_shadowed_column_stream`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Pushed 15109b4: master merged in (the branch was 3839 commits behind), plus the The two reds on c3a043c were job-level timeouts rather than test failures: Integration tests (amd_asan_ubsan, db disk, old analyzer, 3/6) ended with |
|
🕵 Pushed 80a88d4: merged master (the branch was 3899 commits behind; the merge was clean, and both changed translation units compile). The only red on 15109b4 was the coverage job |
| /// subcolumn's serialization, and the streams enumerated from it are the other column's. | ||
| /// Counting them here would mark the array's offsets as rewritten by the mutation and | ||
| /// skip hardlinking them, leaving the new part without them. | ||
| if (!data_part->getColumns().contains(column_name)) |
There was a problem hiding this comment.
getStreamCounts is also the protection for current marker-only READ_COLUMN mutations, not only the CLEAR COLUMN cases added in the new regressions. splitAndModifyMutationCommands still routes a missing-column marker through READ_COLUMN for ALTER MODIFY COLUMN / MATERIALIZE COLUMN, and collectFilesToSkip calls getStreamCounts on updated_header.getNames(). The added tests cover DROP COLUMN, RENAME COLUMN, and CLEAR COLUMN, but they do not exercise that reachable READ_COLUMN path.
Please add a focused stateless regression with skip_empty_columns_on_insert = 1, a marker-only shadowing a.size0, and a READ_COLUMN mutation such as ALTER TABLE ... MODIFY COLUMN \a.size0` Nullable(UInt64) SETTINGS mutations_sync = 2; then verify both SELECT aandCHECK TABLE`.
A column that no source part holds and that has no default expression is dropped from the merged part, and its files are looked up through the part's serialization of that name. Once the column itself is gone from the part, that name resolves to the serialization of a same-named subcolumn of another column - a column named like a subcolumn,
a.size0next to anArraycolumna- so the streams enumerated from it are the other column's. The removal then took the array's offsets file with it, and every read of the table failed:The merged part is left without the offsets file it claims in
columns_substreams.txt, so the data of the array column becomes unreadable -CHECK TABLEcannot repair it either.The removal now takes the serialization from the column entry of the part's column list, and skips a column the list does not hold at all - such a column has no files in the part to remove.
Found while fixing #114588, and reproduces without that change.
The mutation side has the same shape: the wide-part
DROP_COLUMNbranch ofcollectFilesForRenamesinMutateTask.cppalso resolved the dropped name throughIMergeTreeDataPart::tryGetSerialization, so dropping a column the part holds only as a missing-column marker (skip_empty_columns_on_insertwithserialization_info_version = 'with_missing_columns') removed the array's offsets stream from the mutated part. The same rule is applied there, and to theRENAME COLUMNfallback for parts withoutcolumns_substreams.txt.Closes: #118255
Related: #114588
Related: #113420
Related: #92453
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed a merge or a mutation making a table unreadable (
Stream ... is not found) when a column that a part does not hold is dropped and its name is also the name of a subcolumn of another column, for examplea.size0next to anArraycolumna.Workflow [PR]
Sync PR [sync-upstream/pr/118246]
Version info
26.10.1.647-master(included in26.10and later)