Skip to content

Prove the default codec of a Compact part from its shared data file - #119114

Merged
alexey-milovidov merged 7 commits into
masterfrom
compact-part-codec-file-118323
Oct 3, 2026
Merged

alexey-milovidov merged 7 commits into
masterfrom
compact-part-codec-file-118323

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

An all-default-codec Compact part that lacks default_compression_codec.txt could not be attached: ATTACH PART threw CORRUPTED_DATA on a part whose data is intact, and the same detection runs when such a part is loaded.

The Compact leg of the codec proof in detectDefaultCompressionCodec resolved a column's data file through getStreamNameForColumn, which looks for per-column .bin files. A Compact part has none - every column is written into the shared data.bin - so the stream name was empty for every column, the loop proved nothing, and the fallback that reads checksums.txt as a codec frame rejected the part. The one column that resolved was a column literally named data, whose stream name coincides with the shared file, which is why test_default_codec_for_compact_parts passed.

The Compact leg now resolves data.bin directly, which is what the code's own comment describes: the first frame of the shared file proves the default codec once every stored column is known to be default-coded, as the check above it establishes. Wide parts keep the per-column proof.

Closes: #118323

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 ATTACH PART failing with CORRUPTED_DATA for a Compact part whose default_compression_codec.txt is missing, for example a part copied or restored without that file.


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

Version info

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

An all-default-codec Compact part that lacks
`default_compression_codec.txt` could not be attached: the codec proof
resolved a column's data file through `getStreamNameForColumn`, which
looks for per-column `.bin` files. A Compact part has none - every
column is written into the shared `data.bin` - so nothing was proven for
any column and the fallback that reads `checksums.txt` as a codec frame
refused the part with `CORRUPTED_DATA`. A column literally named `data`
was the exception, whose stream name coincides with the shared file;
that coincidence is what kept `test_default_codec_for_compact_parts`
passing.

The Compact leg now resolves `data.bin` directly, which is what the
comment above it describes: the first frame of the shared file proves
the default codec once every stored column is known to be default-coded.

Closes: #118323
@clickhouse-gh

clickhouse-gh Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [dae6ef6]

Summary: ✅


AI Review

Summary

This PR fixes codec recovery for Compact parts whose default_compression_codec.txt is missing by proving the codec from the shared data.bin instead of trying to resolve non-existent per-column .bin files, and it adds regression coverage for both ATTACH PART and subsequent reload. I did not find any remaining correctness, compatibility, or test-coverage issues in the current diff.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit dae6ef6.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.80% +0.10%
Branches 79.50% 79.50% +0.00%

Changed lines: Changed C/C++ lines covered: 15/16 (93.75%) · Uncovered code

Full report · Diff report

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

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing dae6ef6c0 with master b2eae7a4e (stripped binary size, per-symbol sizes and ThinLTO time; 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, 21 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 #119115).

Related: #117449

alexey-milovidov and others added 6 commits September 10, 2026 18:37
… loads again

The reviewer pointed out that the reproducer proved only the `ATTACH PART` half of
the fix for a column not named `data`, while the integration test that reloads the
table still used a column named `data`, the coincidental shape that masked the
original bug.

The stateless test now runs a third `clickhouse local` invocation after the part
becomes active again, so the codec proof also runs on start-up for a part that has
no `default_compression_codec.txt`, and it checks that `system.parts` reports the
recovered codec as `UNKNOWN`. The integration test's column is renamed to `payload`
so its `DETACH TABLE` / `ATTACH TABLE` path exercises the non-coincidental shape too.

The test is renumbered from 05176 to 05227 to follow the tests added on master.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The previous Fast test (arm_darwin) failure (03312_squashing_with_low_card_mem_usage, NOT_ENOUGH_SPACE: Cannot reserve 317.82 MiB) is unrelated: the macOS runner's root volume was 99% full (df -h at the end of https://github.com/ClickHouse/ClickHouse/actions/runs/35990283921/job/107658278747). @groeneai, investigate the failure (disk space on the arm_darwin runner) and provide a fix in a separate PR. If the fix is already in progress, link it here. Merged master to re-run CI.

@groeneai

groeneai commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

This failure is from 2026-09-24 (head 5f237f58): host ip-10-0-31-212 started the job with its 100G root volume 96% full (4.5G free) and ended it at 99% (1.6G free). That was the worst day of this episode, with 33 NOT_ENOUGH_SPACE failures in Fast test (arm_darwin) on 19 PRs.

The fix is already in progress:

@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, though the scenario is strange (why does it happen?)

@alexey-milovidov alexey-milovidov self-assigned this Oct 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 3, 2026
Merged via the queue into master with commit fb2d7ef Oct 3, 2026
150 checks passed
@alexey-milovidov
alexey-milovidov deleted the compact-part-codec-file-118323 branch October 3, 2026 02:17
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 3, 2026
@clickhouse-gh clickhouse-gh Bot added comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... 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

3 participants