Repository navigation
Allow reading MergeTree parts with mixed codecs in one stream - #108592
Conversation
|
Workflow [PR], commit [4d38aef] Summary: ✅
AI ReviewSummaryThis PR makes Missing context / blind spots
Final VerdictStatus: ✅ Approve |
| @@ -120,7 +120,7 @@ void MergeTreeReaderStream::init() | |||
| return pipeline.build(); | |||
| }, | |||
| uncompressed_cache, | |||
| settings.allow_different_codecs); | |||
| /* allow_different_codecs */ true); | |||
There was a problem hiding this comment.
How to be sure that /* allow_different_codecs */ true is set in all places?
Why do we even need reading with /* allow_different_codecs */ false?
There was a problem hiding this comment.
How to be sure that
/* allow_different_codecs */ trueis set in all places?
There is effectively one place to get right. All decompression of part data goes through the MergeTreeReaderStream::init, which is now hardcoded to true. The new gtest pins the uncached CompressedReadBufferFromFile branch of that method. The only other reader of part data is checkDataPart (for CHECK TABLE ...), also set to true. Pinning this one down is very difficult without having adaptive compression. I will add a test in another PR that makes it trivial.
There is no compile time guarantee that some future path for reading part data opts in. But the surface area is small (one reader class).
Why do we even need reading with
/* allow_different_codecs */ false?
Because false is a real integrity check. CompressedWriteBuffer takes one codec at construction and stamps it on every block, so every stream we produce outside the mixed codec ones above (+ spliced Distributed spools sent over network + Compact parts) uses a single codec. Examples are marks files, engine backups, metadata, and single Distributed spool files.
Checking checksums on each block does not cover this. A corrupted method byte would be caught, but a stream wrongly assembled from two codecs (a producer bug, or an older or foreign writer) has each block individually valid, so every checksum on each block would pass and only this check catches it. And it runs independently of the checksum, so it still fires when checksums are off (checksum_on_read=0, or http_native_compression_disable_checksumming_on_decompress). It is one comparison per block, so there is no reason to demote it where the stream really does use a single codec.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 76/76 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This PR removes the allow_different_codecs reader setting and hardcodes the tolerance to always-on in the MergeTree read path. That tolerance branch only does work when adjacent compressed blocks within one stream use different codecs; for the single-codec column streams ClickBench scans, the change is a no-op, so it cannot plausibly shift query timings in either direction. The four flagged queries (improvements on Q4/Q15, regressions on Q31/Q32) are all on this read path yet move both ways, which points to run-to-run variance rather than a real effect, so all four are downgraded to not-sure. No query crosses the large-and-consistent threshold that would force a verdict to stand. clickbenchFlagged queries (4 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
|
Hi @rienath @CheSema — while reviewing this PR I found the following:
Could you review the test PR and add the |
Cherry pick #108592 to 26.3: Allow reading MergeTree parts with mixed codecs in one stream
Cherry pick #108592 to 26.4: Allow reading MergeTree parts with mixed codecs in one stream
Cherry pick #108592 to 26.5: Allow reading MergeTree parts with mixed codecs in one stream
Backport #108592 to 26.6: Allow reading MergeTree parts with mixed codecs in one stream
Backport #108592 to 26.3: Allow reading MergeTree parts with mixed codecs in one stream
Backport #108592 to 26.4: Allow reading MergeTree parts with mixed codecs in one stream
Backport #108592 to 26.5: Allow reading MergeTree parts with mixed codecs in one stream
Allow reading MergeTree parts with mixed codecs in one stream
This is the read side of the adaptive codec selection RFC (#105404). The write side chooses a codec per block during merges and mutations, producing streams whose consecutive blocks use different codecs. Today the reader rejects such a stream with
CANNOT_DECOMPRESSas soon as two consecutive blocks have different method bytes, unlessallow_different_codecsis set. This PR makes the reader tolerate different codecs in one stream.No writer produces mixed-codec parts yet, so on its own this PR has no observable effect. It needs backporting down to 26.3, well before any writer can create such parts. During a rolling upgrade or rollback, a replica running the experimental
allow_experimental_adaptive_codec_selectioncould write a multi-codec column, so every replica that might fetch that part must already be able to read it. Backporting the reader tolerance first closes that window.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
MergeTree can now read a compressed stream whose blocks use different codecs. This is the read-side prerequisite for adaptive codec selection (#105404).
Version info
26.6.2.68,26.5.6.38,26.4.5.126,26.3.17.42