Skip to content

Do not remove another column's stream with a dropped marker column - #119115

Closed
alexey-milovidov wants to merge 7 commits into
masterfrom
drop-marker-column-subcolumn-name-118255
Closed

alexey-milovidov wants to merge 7 commits into
masterfrom
drop-marker-column-subcolumn-name-118255

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

With skip_empty_columns_on_insert = 1 and serialization_info_version = 'with_missing_columns', an INSERT that leaves a column at its type default records it as a missing-column marker instead of writing stream files. ALTER TABLE ... DROP COLUMN of such a marker named like a generated subcolumn of another column - a column named a.size0 next to an Array column a - removed the array's offsets stream from the mutated part, and every subsequent read of a failed with a logical error:

Code: 49. DB::Exception: Stream a.size0 for column a with type Array(UInt64) is not found

The wide-part DROP_COLUMN branch of collectFilesForRenames looked the dropped name up through the part's serializations. The marker column has no serialization of its own there, so the name resolved to the serialization of the array's a.size0 subcolumn and the stream enumerated from it was the array's offsets file; the shared-stream counter reached zero because the marker contributed no streams of its own, and the mutation removed the file.

The dropped column's serialization now comes from the part's own column entry, and a column the part holds no data for has no files to remove at all. The wide-part RENAME_COLUMN fallback for parts without columns_substreams.txt did the same name lookup, so both branches go through one helper that skips stream enumeration for such a column. On the rename side this is defensive: the fallback computes the target by replacing the escaped column name (a%2Esize0), which the offsets file (a.size0) does not contain, and the shapes where it would match are rejected by the stream file name collision check on ADD COLUMN; the second test pins the invariant rather than a live corruption. This is the mutation-side sibling of the read side (#114588) and the merge side; the fix has the same shape as the merge one.

Closes: #118255

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 to CHANGELOG.md):

Fixed ALTER TABLE ... DROP COLUMN of a column that a part records as a missing-column marker deleting another column's stream from the mutated part when the dropped column is named like a subcolumn of that column, such as a.size0 next to an Array column a. Reads of the array failed with a logical error afterwards.


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

A column that a part records as a missing-column marker has no streams
of its own, and the dropped name was looked up in the part's
serializations. For a marker named like a subcolumn of another column
(`a.size0` next to an `Array` column `a`) that name resolves to the
subcolumn's serialization, so the mutation of a `DROP COLUMN` removed
the array's offsets file from the new part and every read of the array
failed with a logical error afterwards.

The dropped column's serialization now comes from the part's own column
entry, and a column the part holds no data for has no files to remove.
This is the mutation-side sibling of the read side (issue #114588) and
of the merge side, and takes the same shape as the merge-side fix.

Closes: #118255
@clickhouse-gh

clickhouse-gh Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a51c6b0]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_tsan, 6/6) FAIL
test_storage_kafka/test_multi_consumer_quota.py::test_multi_consumer_with_partition_affinity FAIL cidb
Upgrade check (amd_release) FAIL
Cannot check whether the mutation submitted before the upgrade was finished (see mutation_across_upgrade_error.txt) FAIL cidb
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb
Performance Comparison (arm_release, master_head, 2/6) FAIL Performance dashboard
sparse_grams_index_build #0 FAIL dashboard
sparse_grams_index_build #1 slower query history
Integration tests (amd_tsan, 3/6) ERROR
Timeout FAIL cidb

AI Review

Summary

This PR fixes the wide-part mutation path so a marker-only column is no longer resolved through the part's subcolumn-aware serialization lookup when DROP COLUMN or the old-part RENAME COLUMN fallback enumerates streams. That closes the real corruption on DROP COLUMN for names like a.size0, and the added stateless tests cover both the live DROP COLUMN failure and the rename-side invariant that marker-only renames leave unrelated streams intact. I did not find any remaining correctness issues in the current diff.

Final Verdict

✅ Approved

LLVM Coverage Report

Measured on commit a51c6b0.

Metric Baseline Current Δ
Lines 88.20% 88.10% -0.10%
Functions 91.70% 91.70% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 14/14 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-mutations ALTER UPDATE/DELETE and mutation execution over parts (including lightweight updates/deletes). labels Sep 10, 2026
Comment thread src/Storages/MergeTree/MutateTask.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing a51c6b03c with master b014c166a (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 875485ad7; 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

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

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Fast test (arm_darwin) failure is unrelated to this change: 05076_error_trace_file_offsets returns 1 0 instead of 1 1 on macOS, and the same failure appears on other pull requests that touch nothing near it (for example #119114).

Related: #117449

alexey-milovidov and others added 3 commits September 10, 2026 18:37
The wide-part `RENAME_COLUMN` fallback of `collectFilesForRenames` (the
path for parts without `columns_substreams.txt`, which a missing-column
marker is always absent from) looked the renamed column's serialization
up in the part by name, exactly like the `DROP_COLUMN` branch did before.
For a marker named like a subcolumn of another column (`a.size0` next to
an `Array` column `a`) that lookup resolves to the array's offsets
serialization.

Both branches now go through one helper,
`getSerializationOfPhysicalColumn`, that returns the serialization from
the part's own column entry and nothing for a column the part holds no
data for: such a column has no stream files to remove or rename.

Add `05228_rename_marker_column_named_like_subcolumn` for the rename
side (`Array` and `Nested`, plus a physically written column of the same
name), and renumber the drop test to `05227` because `05177` is taken on
master now.

Addresses the review thread
#119115 (comment)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
alexey-milovidov and others added 3 commits September 18, 2026 11:30
The `RENAME_COLUMN` fallback computes the target by replacing the escaped
column name (`a%2Esize0`) in the stream file name, which the array's offsets
file (`a.size0`) does not contain, so the pre-fix code emitted no rename for
the tested shapes. The shapes where the escaped name does match (a marker
`t.x` next to `t Tuple(x ...)`) are rejected by the stream file name
collision check on `ADD COLUMN` (verified on a pre-fix binary), so no case
can fail before the fix. Reword the test header to say it pins the invariant.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Closing as already fixed on master. The same issue (#118255) was fixed by #118246 (commit c3a043c4644, merged 2026-09-25). That commit is an ancestor of origin/master at e3e346d4751. Master's collectFilesForRenames now has try_get_serialization_of_stored_column, which skips stream enumeration for a column the source part does not physically store. It covers both the DROP COLUMN path and the RENAME COLUMN fallback path, which are the two call sites this PR changed. Merging master into this branch conflicted at exactly those two lines.

To verify, I took master's MutateTask.cpp unchanged and built it. This PR's own tests, 05227_drop_marker_column_named_like_subcolumn and 05228_rename_marker_column_named_like_subcolumn, pass against that build, and so does master's 05175_mutation_drops_shadowed_column_stream. That leaves only the tests in this PR, and they mostly duplicate 05175, so nothing here needs to land.

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-bugfix Pull request with bugfix, not backported by default

Projects

None yet

1 participant