Skip to content

Add test: Mixed-codec stream read through CachedCompressedReadBuffer (use_uncompressed_cache=1) is untested - #108877

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr108592
Jul 4, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr108592

Conversation

@clickgapai

@clickgapai clickgapai commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #108592.
That PR (1) The PR makes the MergeTree reader tolerate a single compressed stream whose consecutive blocks use different codecs (the read side of adaptive codec selection, RFC #105404). It deletes the MergeTreeReaderSettings::allow_different_codecs flag and instead hardcodes `allow_different_codecs = true

1. Mixed-codec stream read through CachedCompressedReadBuffer (use_uncompressed_cache=1) is untested
src/Storages/MergeTree/MergeTreeReaderStream.cpp:123
Risk: MergeTreeReaderStream::init picks the buffer by else if (uncompressed_cache) (line 105): with use_uncompressed_cache=1 and the server's uncompressed-cache object present, it builds CachedCompressedReadBuffer(..., /* allow_different_codecs */ true) (line 123); that buffer reuses one instance across the stream's blocks, so a ZSTD block followed by a NONE block must be tolerated. RISK: if this flag regresses to false, every read of a mixed-codec (Compact/adaptive) part with the …
What's unique vs PR tests: The PR's 04409 test and the gtest both read the mixed-codec stream through CompressedReadBufferFromFile/CompressedReadBuffer (no uncompressed cache). This test adds use_uncompressed_cache=1, the only way to reach the separate CachedCompressedReadBuffer branch (line 123), whose flag the PR also flipped but no test covers.
Tags: -- Tags: no-random-merge-tree-settings — no-random-merge-tree-settings: randomized min_bytes/min_rows_for_wide_part would turn the part Wide, splitting columns into separate single-codec streams and losing the mixed-codec scenario.
Try it on ClickHouse Fiddle

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.7.1.509 (included in 26.7 and later)

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
MergeTreeReaderStream.cpp:123 — CachedCompressedReadBuffer(..., /* allow_different_codecs */ true) branch (reached only when uncompressed_cache is non-null, i.e. use_uncompressed_cache=1) is correct but exercised by no test.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04489_compact_part_mixed_codec_uncompressed_cache.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cebc24e]

Summary: ✅


AI Review

Summary

This PR adds a stateless regression test for the compact-part mixed-codec read path behind use_uncompressed_cache = 1. I traced the current flow from ReadFromMergeTree through MergeTreeReadPoolBase into MergeTreeReaderCompactSingleBuffer/MergeTreeReaderStreamAllOfMultipleColumns, verified that the query stays below the default merge_tree_max_*_to_use_cache cutoffs, and did not find a remaining correctness, coverage, or PR-metadata issue.

Final Verdict
  • Status: ✅ Approve

@alexey-milovidov alexey-milovidov self-assigned this Jun 30, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 30, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Continued via /continue-pr.

Merged master in (f786720acd2): the branch was ~3755 commits / 11 days behind master and red, so I merged the current base. The merge was clean (no conflicts); the net diff vs master is exactly the PR's two test files (+18 lines). PR #108592 — the change this test covers — has since been merged to master (298379758, 2026-06-29), so the targeted branch is now present unconditionally: MergeTreeReaderStream.cpp:105-123 constructs CachedCompressedReadBuffer(..., /* allow_different_codecs */ true) in the else if (uncompressed_cache) path, reached only with use_uncompressed_cache = 1, which is exactly what the test exercises.

The only CI failures are an unrelated master-wide flake. Stress test (amd_tsan) and Stress test (arm_tsan) both failed with Hung check failed, possible deadlock found — the CI summary itself links these to #107941. CIDB confirms this is pervasive and not caused by this change: in the last 24h (2026-06-30) there were 147 such failures across dozens of unrelated PRs (this PR included), and 182 the day before. The hung-check stacks are in InterpreterSelectQueryAnalyzer / AST-fuzzer query execution, with no connection to a stateless test that creates a Compact MergeTree part and reads it twice. All builds and all functional/stateless jobs are green.

The test is well-formed: it forces a Compact part via min_*_for_wide_part, mixes CODEC(ZSTD) and CODEC(NONE) in one shared stream, reads twice under use_uncompressed_cache = 1 (second read hits the populated cache), and the reference values are correct (count = 100000, sum(0..99999) = 4999950000). The 04489_ numeric prefix is shared with 04489_max_threads_auto_parsing_compat on master, which is tolerated (the runner keys on the full filename). AI Review verdict is ✅ Approve, no unresolved review threads.

Blocked only on a fresh CI run and maintainer merge.

@alexey-milovidov

Copy link
Copy Markdown
Member

Refreshed via /continue-pr (b41e4d41b8e).

Re-merged current master into the branch: it was ~182 PRs / 3 days behind since the last merge (f786720a, 2026-06-30) and red only from the unrelated flake below, so I merged the latest base to get a fresh CI signal. The merge was clean (no conflicts); the net diff vs master is still exactly the PR's two test files (+18 lines), with no exact-filename collision on 04489_.

The covered code path is still present on latest master. MergeTreeReaderStream.cpp:105-123 constructs CachedCompressedReadBuffer(..., /* allow_different_codecs */ true) in the else if (uncompressed_cache) branch, reached only with use_uncompressed_cache = 1 — exactly what the test exercises. PR #108592 (the change under test) remains merged.

The prior CI reds were the unrelated master-wide flake #107941 (Hung check failed, possible deadlock found), still OPEN, which the CI summary itself linked. Not caused by a stateless test that creates a Compact MergeTree part and reads it twice.

I re-verified the test's output locally (Compact, then 100000 4999950000 4999950000 twice — matches the reference exactly). AI Review verdict is ✅ Approve; no unresolved review threads. Blocked only on a fresh CI run and maintainer merge.

@alexey-milovidov

Copy link
Copy Markdown
Member

Merged the latest master into this branch to pull in #109254 (Skip 04319_skip_unavailable_shards_mode_table_missing on macOS fast test), which fixes the Fast test (arm_darwin) failure that was blocking this PR. The net diff is unchanged — still only the two test files (+18). CI is re-running; the only red that could remain is the Stress test (amd_tsan) Hung check flake (#107941), a master-wide flake unrelated to this stateless read test.

@clickhouse-gh

clickhouse-gh Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.81% 85.82% +0.01%
Functions 91.47% 91.47% +0.00%
Branches 78.31% 78.35% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 91 line(s), 3 function(s) across 43 file(s) · Details

Top files
  • src/Common/ColumnsHashing.h: 8 line(s), 2 function(s)
  • src/Functions/if.cpp: 8 line(s)
  • src/Storages/MergeTree/MergeFromLogEntryTask.cpp: 7 line(s)
  • src/Functions/s2GetNeighbors.cpp: 6 line(s)
  • src/Functions/h3ExactEdgeLengthKm.cpp: 4 line(s)

Full report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 4, 2026
Merged via the queue into ClickHouse:master with commit f9dd12e Jul 4, 2026
174 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 4, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…pr108592

Add test: Mixed-codec stream read through `CachedCompressedReadBuffer` (`use_uncompressed_cache=1`) is untested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog 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.

3 participants