Skip to content

Fix columns_substreams.txt corruption during column rename in some cases - #102689

Merged
alexey-milovidov merged 4 commits into
masterfrom
fix-substreams-rename-bug
May 3, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
fix-substreams-rename-bug

Conversation

@Avogar

@Avogar Avogar commented Apr 14, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fix columns_substreams.txt corruption during column rename in some cases. Closes #102259

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Backported to: 26.4.1.1140, 26.3.10.61, 26.2.19.13

@clickhouse-gh

clickhouse-gh Bot commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9cc071c]

Summary: ❌

job_name test_name status info comment
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb
Performance Comparison (arm_release, master_head, 2/6) FAIL
Check Results FAIL

AI Review

Summary

This PR fixes a real columns_substreams.txt corruption bug in RENAME COLUMN handling by correcting suffix extraction in ISerialization::getFileNameForRenamedColumnStream. The change is small, targeted, and aligns with the linked issue. Added stateless coverage validates both plain Array and Nested rename paths, including the nested storage-name branch. Based on the current diff, I did not find additional correctness, safety, or performance problems.

Missing context
  • ⚠️ Full CI signal is not yet available (Code Review, Fast test, Build (arm_tidy), and bugfix functional validation are still running at review time).
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Apr 14, 2026

@yakov-olkhovskiy yakov-olkhovskiy left a comment

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.

fix seems correct, but reference for test is incorrect - seems incorrectly generated by AI?

@yakov-olkhovskiy yakov-olkhovskiy self-assigned this Apr 14, 2026
@Avogar

Avogar commented Apr 17, 2026

Copy link
Copy Markdown
Member Author

but reference for test is incorrect - seems incorrectly generated by AI?

No, it's because of settings randomization, specifically because of sparse serialization. I will update the test

@clickhouse-gh

clickhouse-gh Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.00% -0.10%
Functions 91.10% 91.10% +0.00%
Branches 76.60% 76.50% -0.10%

Changed lines: 100.00% (6/6) · Uncovered code

Full report · Diff report

alexey-milovidov added a commit that referenced this pull request May 2, 2026
After PR #103917 silenced the `Tuple element name 'null' is reserved`
rejection, the upgrade check now surfaces a different pre-existing
issue: parts of `02538_alter_rename_sequence`'s `wrong_metadata_wide`
table are detached as broken on the upgraded server with messages like

    No stream (column1_renamedcolumn1.bin) file checksum for column
    column1_renamed in part ...

This is the bug tracked by issue #102259 (`getFileNameForRenamedColumnStream`
uses `substr(0, N)` instead of `substr(N)`, corrupting `columns_substreams.txt`
after `RENAME COLUMN`) and the still-open fix in PR #102689.

Until those land, allowlist any error referencing the test's
`wrong_metadata_wide` table so the upgrade check is not blocked by this
unrelated bug. The allowlist substring is the table name, which is unique
to `02538_alter_rename_sequence`, so it does not mask other failures.

Failing run on this PR:
https://s3.amazonaws.com/clickhouse-test-reports/PRs/103917/f62aefdf8983dbeb089bab0a8d8b7f14e71849d8/upgrade_check_amd_release/test_results.tsv

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alexey-milovidov
alexey-milovidov merged commit 443a458 into master May 3, 2026
157 of 161 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-substreams-rename-bug branch May 3, 2026 13:51
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 3, 2026
robot-ch-test-poll1 added a commit that referenced this pull request May 3, 2026
Cherry pick #102689 to 25.8: Fix columns_substreams.txt corruption during column rename in some cases
robot-clickhouse added a commit that referenced this pull request May 3, 2026
robot-ch-test-poll1 added a commit that referenced this pull request May 3, 2026
Cherry pick #102689 to 26.2: Fix columns_substreams.txt corruption during column rename in some cases
robot-clickhouse added a commit that referenced this pull request May 3, 2026
robot-ch-test-poll1 added a commit that referenced this pull request May 3, 2026
Cherry pick #102689 to 26.3: Fix columns_substreams.txt corruption during column rename in some cases
robot-clickhouse added a commit that referenced this pull request May 3, 2026
robot-ch-test-poll1 added a commit that referenced this pull request May 3, 2026
Cherry pick #102689 to 26.4: Fix columns_substreams.txt corruption during column rename in some cases
robot-clickhouse added a commit that referenced this pull request May 3, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 3, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 3, 2026
alexey-milovidov added a commit that referenced this pull request May 5, 2026
Backport #102689 to 26.4: Fix columns_substreams.txt corruption during column rename in some cases
maxknv pushed a commit to groeneai/ClickHouse that referenced this pull request May 6, 2026
PR ClickHouse#103917 narrowed the `wrong_metadata_wide` allowlist to the specific
corrupted-filename signature emitted by `02538_alter_rename_sequence` after
the `getFileNameForRenamedColumnStream` `substr(0, N)` bug (issue ClickHouse#102259,
fix in PR ClickHouse#102689). The same bug also surfaces on
`02555_davengers_rename_chain`'s `wrong_metadata` table, but with a
different column/stream pair, so the narrow regex did not catch it and
the upgrade check began failing on unrelated PRs.

Add the matching narrow signatures:

* `No stream (ba1.bin) file checksum for column b` — the chained rename
  `a -> a1 -> b` produces `<new=b><old=a1>.bin = ba1.bin` for column `b`.
  This `<column><stream>` combination is unique to that test and that bug.
* Loosen `wrong_metadata_wide` to `wrong_metadata` in the secondary
  `Detaching broken part` regex so it matches both narrow and wide table
  variants. The other two substrings (`Detaching broken part` +
  `backward incompatibility`) keep the allowlist scoped to the same
  symptom.

Verified against the failing log
(https://s3.amazonaws.com/clickhouse-test-reports/PRs/103874/49885046aba0893d06655439d554aeac6998469e/upgrade_check_amd_release/upgrade_error_messages.txt):
all six lines are filtered, while synthetic unrelated errors (other
tables, generic detach notices, log lines that mention the table name in
passing) pass through.

Source PR with the failing run: ClickHouse#103874
alexey-milovidov added a commit that referenced this pull request May 6, 2026
Backport #102689 to 26.3: Fix columns_substreams.txt corruption during column rename in some cases
fm4v added a commit that referenced this pull request May 12, 2026
Backport #102689 to 26.2: Fix columns_substreams.txt corruption during column rename in some cases
@rschu1ze rschu1ze added the pr-backport Changes, backported to release branch. Do not use manually - automated use only! label May 14, 2026
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Jun 15, 2026
Backport of ClickHouse#102689 to 25.8.16: Fix columns_substreams.txt corruption during column rename in some cases
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Jul 24, 2026
Antalya 25.8, backport of ClickHouse#102689: Fix columns_substreams.txt corruption during column rename in some cases
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 12, 2026
loadColumnsSubstreams discards a Wide part's columns_substreams.txt when a
substream name has a prefix that does not match its column (the rename bug fixed
in ClickHouse#102689), returning without installing anything. The empty-columns.txt
recovery then reached getFirstFileNameForColumn with no substreams and no
serializations, so presence fell through to the default serialization's first
stream. A column stored in any other layout has no such stream, so it was judged
absent, left out of the rebuilt list, and writeColumns persisted the omission.

Measured on a bucketed Map (m.buckets_info, m.0.keys, ... vs the default
m.size0, m.keys): sum(length(m)) went 4000 -> 0 with the part still active and
columns.txt rewritten without m, i.e. an intact column reading back as defaults.
Repairing columns_substreams.txt afterwards did not undo it - the persisted list
then disagreed with the file and validateColumns raised a LOGICAL_ERROR on load.

Refusing leaves the part detached and hand-recoverable instead. The predicate is
exact: MergedBlockOutputStream only writes the file when it is non-empty, so
present-but-empty is uniquely the discarded case. A part that never had the file
still takes the stream-enumeration fallback, and an intact part with a valid file
still recovers, both covered by existing cases in 04545.

The new case corrupts whichever substream comes first rather than a fixed name:
randomized serialization versions change which streams a column produces, and a
name-specific edit silently became a no-op on some runs, making the arm pass
without ever corrupting anything.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…2689

Backport ClickHouse#102689 to 26.4: Fix columns_substreams.txt corruption during column rename in some cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! 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.

getFileNameForRenamedColumnStream uses substr(0, N) instead of substr(N), corrupting columns_substreams.txt after RENAME COLUMN

6 participants