Skip to content

Resolve a pending rename of a Nested leaf read as a subcolumn - #119134

Merged
alexey-milovidov merged 12 commits into
masterfrom
nested-leaf-pending-rename-118157
Oct 11, 2026
Merged

alexey-milovidov merged 12 commits into
masterfrom
nested-leaf-pending-rename-118157

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

While an ALTER TABLE ... RENAME COLUMN of a Nested leaf was pending, every SELECT of the renamed leaf from a wide part returned default values at default settings:

CREATE TABLE tn (id UInt8, `n.a` Array(UInt8), `n.b` Array(String))
ENGINE = MergeTree ORDER BY tuple() SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO tn VALUES (1, [7,8], ['x','y']);
SYSTEM STOP MERGES tn;   -- stands in for a mutation that is still running
ALTER TABLE tn RENAME COLUMN n.b TO n.z SETTINGS alter_sync = 0;

SELECT id, n.a, n.z FROM tn;   -- 1  [7,8]  ['','']  (correct: ['x','y'])

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.

AlterConversions records the rename under the flattened name n.z, while the reader asks for the leaf as the subcolumn z of the parent n (Nested::convertToSubcolumns, the default with share_nested_offsets). The rename lookup in getStorageAndSubcolumnNameInPart asks 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 = 0 were unaffected and are unchanged.

Closes: #118157

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 reads of a renamed Nested leaf column returning default values from wide parts while the RENAME COLUMN mutation was still pending.


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

Version info

  • Merged into: 26.10.1.2157-master (included in 26.10 and later)

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
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0642ed3]

Summary: ✅


AI Review

Summary

This PR fixes IMergeTreeReader so a pending RENAME COLUMN of a Nested leaf is resolved through the flattened leaf name, including dotted leaf names and leaf subcolumns, instead of reading defaults from wide parts. The reader-side change matches the current Nested metadata, the added stateless tests cover the original regression plus the multi-dot, prefix-sharing, and JSON / Dynamic mutation cases, and I do not see a remaining correctness issue in the current diff.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 0642ed3.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.70% 79.70% +0.00%

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

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 10, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0642ed366 with master 468fbe0bb (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 33e5818c7; 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, 15 s compile time in total, 7 of them have a recent master baseline.

Job report

alexey-milovidov and others added 3 commits September 10, 2026 18:38
`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]>
alexey-milovidov and others added 3 commits September 25, 2026 13:30
…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]>
@zlareb1

zlareb1 commented Sep 29, 2026

Copy link
Copy Markdown
Member

@PedroTadim

Copy link
Copy Markdown
Member

@alexey-milovidov are we going to merge this soon?

alexey-milovidov and others added 3 commits October 3, 2026 16:53
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]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @zlareb1, thanks for the reproducer in #118157 (comment). With this PR, the RENAME COLUMN mutation keeps the data of Array(JSON) and Array(Dynamic) leaves of a Nested column (['{"x":1}','{"x":2}'] and [1,'x'], also after renaming back). I added this case as the test 05325_rename_nested_leaf_json_dynamic_mutation. I also merged master, which brings in the fix for the Build (amd_fuzzers) link failure.

@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.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Oct 11, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 11, 2026
Merged via the queue into master with commit 87f10d9 Oct 11, 2026
149 checks passed
@alexey-milovidov
alexey-milovidov deleted the nested-leaf-pending-rename-118157 branch October 11, 2026 21:15
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 11, 2026
valerypetrov pushed a commit to valerypetrov/ClickHouse that referenced this pull request Oct 13, 2026
`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]>
JTCunning pushed a commit to JTCunning/ClickHouse that referenced this pull request Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

4 participants