Repository navigation
Do not estimate a column's compressed size with a codec its sample does not match - #118335
Conversation
…es not match
The input-bytes estimate for a compact part serializes a sample of every column it
reads and compresses it with the column's `CODEC`, resolved once per read task from
the table metadata. The metadata does not describe that sample on its own, and the
estimate used the type-specific codec regardless:
- the serialization is chosen per block from the column at hand, so a column stored
`Sparse` (or `Replicated`) arrives as several substreams funnelled into one buffer;
- a column read from a part keeps its pre-`ALTER` type until the mutation that
rewrites it has run, while the codec was resolved for the new type.
A type-specific codec then measures a stream it was never resolved for. Most only
mismeasure it, but `ALP` validates its input and fails the query outright:
Cannot compress with ALP(RD) codec, data size 19209 is not aligned to 4.
(CANNOT_COMPRESS)
Resolve both the type-specific and the generic-only codec up front and pick between
them from the serialization and the type the sample actually has, keeping only the
generic codecs for every other shape - exactly what the writer does for structural
substreams.
Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=3324e948a5143641935d0389afbe55193545c4f2&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29
Caused by: #114535
|
Workflow [PR], commit [2a455ec] Summary: ✅
AI ReviewSummaryThis PR fixes the compact-part input-bytes estimator so it stops recompressing samples with a type-specific Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit 2a455ec.
Changed lines: Changed C/C++ lines covered: 44/44 (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 units20 translation units recompiled, 182 s compile time in total, 20 of them have a recent master baseline. |
Related: #114535
The AutoPR input-bytes estimate for a compact part serializes a sample of every column it reads and compresses it with the column's
CODEC, resolved once per read task from the table metadata. The metadata does not describe that sample on its own, and the estimate applied the type-specific codec regardless:Sparse(orReplicated) arrives as several substreams funnelled into one buffer;ALTERtype until the mutation that rewrites it has run, while the codec was resolved for the new type.A type-specific codec then measures a stream it was never resolved for. Most only mismeasure it, but
ALPvalidates its input and fails the query outright:This broke
04035_alp_rd_codec_special_valuesand03743_alp_codec_special_valueson master whenever the settings randomizer turned on both automatic parallel replicas and sparse serialization. The failures start on 2026-09-05, the day #114535 was merged, and there is no open issue tracking them.Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=3324e948a5143641935d0389afbe55193545c4f2&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29
The fix resolves both the type-specific and the generic-only codec up front and picks between them from the serialization and the type the sample actually has, keeping only the generic codecs for every other shape - exactly what the writer does for structural substreams.
Both triggers are reproduced by the new test
05099_autopr_input_bytes_estimation_sparse_column_codec, which fails on master and passes here.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/118335]
Version info
26.9.1.850(included in26.9and later)