Repository navigation
Resolve a pending rename of a Nested leaf read as a subcolumn - #119134
Conversation
The reader asks for a leaf of a Nested column as a subcolumn of its parent (`n.z` becomes the subcolumn `z` of `n`), while a pending rename of that leaf is recorded under the flattened name `n.z`. The rename lookup asked for the parent alone, so it missed, and the part was searched for a column that exists there only under its old name: the values of the column read as defaults for as long as the mutation was pending, with correct array sizes from the shared offsets stream. Closes: #118157
|
Workflow [PR], commit [0642ed3] Summary: ✅
AI ReviewSummaryThis PR fixes Final Verdict
LLVM Coverage ReportMeasured on commit 0642ed3.
Changed lines: Changed C/C++ lines covered: 18/18 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 15 s compile time in total, 7 of them have a recent master baseline. |
`Nested::splitName` splits a column name at the first dot, so `n.b.c` is the leaf `b.c` of `n`, and `RENAME COLUMN` may change any part of the leaf name as long as the parent stays the same (`n.b.c` to `n.x.y`). The rename lookup in `IMergeTreeReader::getStorageAndSubcolumnNameInPart` only probed the rename map with the first segment of the subcolumn name (`n.x`), so such a leaf was still read as defaults from wide parts while the rename was pending. Every dotted prefix of the subcolumn name is now tried, longest first, which also keeps a real subcolumn of the renamed leaf (`n.x.null`, `n.x.y.size0`) after the resolved old leaf name. The test is renumbered to 05227 because 05178 is taken on master now, and covers the dotted leaf and the subcolumn suffixes. Addresses the review thread #119134 (comment) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…t metadata Shortening the subcolumn name until a pending rename matched could take an unchanged leaf `n.x.y` for the subcolumn `y` of `n.x` when `n.b` is being renamed to `n.x`, and read `n.b.y` (defaults) instead. Pick the longest element name of the `Nested` type as the leaf instead. Addresses review: #119134 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… prefix-sharing leaf case Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
@alexey-milovidov are we going to merge this soon? |
For `JSON` and `Dynamic` leaves the `RENAME COLUMN` mutation rewrites the part and reads the leaf through the same lookup, so before this fix it wrote defaults into the new part and the data was lost for good. Cover that case, reported in #118157 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @zlareb1, thanks for the reproducer in #118157 (comment). With this PR, the |
`ClickHouseCluster.start` ran the MongoDB and MinIO `docker compose up`
once, so a transient per-container daemon error lost the whole module.
On 26.7 the MongoDB up failed with
failed to create endpoint roottesttablefunctionmongodb-gw0-mongo1-1 on
network roottesttablefunctionmongodb-gw0_default: failed to add the host
(veth2d10e1f) <=> sandbox (veth2d10e1f) pair interfaces: file exists
and all 16 tests of `test_table_function_mongodb` failed:
https://github.com/ClickHouse/ClickHouse/actions/runs/38284747320/job/114936343879
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=26.7&sha=bc135b699eafe550939f3eb17885f541f5dfa226&name_0=ReleaseBranchCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%205%2F8%29
CI's docker-ce 27.0.3 draws the host-side and the container-side veth
names independently and never compares them, so with probability 2^-28
per endpoint both ends get the same name and the pair cannot be created.
The same error hit the MinIO up on
ClickHouse#119134
(https://github.com/ClickHouse/ClickHouse/actions/runs/36144124883/job/108126010556),
and an OOM-killed container init failed it on master
(https://github.com/ClickHouse/ClickHouse/actions/runs/33353696579/job/99381397549).
`up -d` converges: running containers are left alone and the container
left in `created` state is started, so another attempt recovers. Add a
`compose_up` helper with the retry the ZooKeeper/Keeper and ClickHouse
node ups already use (ClickHouse#99525, ClickHouse#122343), and route those three sites and
the MongoDB and MinIO ups through it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
While an
ALTER TABLE ... RENAME COLUMNof a Nested leaf was pending, everySELECTof the renamed leaf from a wide part returned default values at default settings:The array sizes stayed correct, because the shared offsets stream is found either way, so nothing looked broken: aggregates, filters and joins over the column quietly computed over empty values, and the results became right again once the mutation materialized.
AlterConversionsrecords the rename under the flattened namen.z, while the reader asks for the leaf as the subcolumnzof the parentn(Nested::convertToSubcolumns, the default withshare_nested_offsets). The rename lookup ingetStorageAndSubcolumnNameInPartasks for the parent, misses, and the part is searched for a column that exists there only under the old name; the wide reader then finds the offsets but no values stream and the missing values are legitimately default-filled.A Nested leaf requested as a subcolumn of its parent now also looks the flattened name up in the rename map. Compact parts and
share_nested_offsets = 0were unaffected and are unchanged.Closes: #118157
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed reads of a renamed
Nestedleaf column returning default values from wide parts while theRENAME COLUMNmutation was still pending.Workflow [PR]
Sync PR [sync-upstream/pr/119134]
Version info
26.10.1.2157-master(included in26.10and later)