Repository navigation
Conversation
Pin read_in_order_two_level_merge_threshold to prevent the randomized value (0-100) from triggering a two-level merge pipeline when the number of parts exceeds the threshold. Root cause: INSERT with max_insert_threads=8 creates ~8 parts. When read_in_order_two_level_merge_threshold is randomized below this count (e.g. 6), the read-in-order pipeline switches to a two-level merge structure. Combined with max_streams_to_max_threads_ratio=8 (used in the last test query), the aggregation collapses to 1 thread, eliminating the expected Resize 1 → 4 step from the pipeline output. Closes ClickHouse#101657 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pre-PR Validation Gate (Session: cron:clickhouse-ci-task-worker:20260415-134500)a) Deterministic repro? ✅ Yes. Create a table with 8+ unmerged parts, set b) Root cause explained? ✅ c) Fix matches root cause? ✅ Pins d) Test intent preserved? ✅ The test verifies e) Both directions demonstrated? ✅ With 9 parts and |
|
cc @vdimir — could you review this? It pins |
|
Workflow [PR], commit [2625f0d] Summary: ✅ AI ReviewSummaryThis PR stabilizes ClickHouse Rules
Final Verdict
|
…ree-memory limiter The test exercises `EXPLAIN PIPELINE` with `max_threads=32` and asserts the resulting pipeline contains `Resize 16 → 32`. Since ClickHouse#100383 (`Limit max_threads and max_insert_threads based on available free memory`), `max_threads` is trimmed when free memory is below `max_threads_min_free_memory_per_thread` (default 1 GiB) per requested thread. On `Stateless tests (amd_llvm_coverage_per_test, per_test_coverage, 7/8)` the per-test coverage instrumentation reduces available memory, so the limiter clamps the requested 32 threads to ~24 and the test fails: ``` - Resize 16 → 32 - MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 16 0 → 1 + Resize 16 → 24 + MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 16 0 → 1 ``` Disable both `max_threads_min_free_memory_per_thread` and `max_insert_threads_min_free_memory_per_thread` in the test SET block so the requested thread count is preserved regardless of concurrent memory pressure. Same fix pattern applied to `02343_aggregation_pipeline.sql` in the original PR (commit de505d1). The test had its last master failure on the wave introduced by ClickHouse#100383 on 2026-05-02 03:55 UTC, ~4 hours after ClickHouse#100383 merged on 2026-05-01 23:22 UTC. CIDB shows 10 master hits in the 14-day window since, all on `per_test_coverage`. The related auto-generated `Flaky test` issue ClickHouse#101657 covers an older failure mode that was fixed by ClickHouse#102818; this PR addresses a separate failure mode introduced by ClickHouse#100383. **Reproduction (deterministic):** ```bash PATH=build/programs:$PATH \ CLICKHOUSE_CLIENT_OPT='--max_threads_min_free_memory_per_thread=24000000000 --max_insert_threads_min_free_memory_per_thread=24000000000' \ tests/clickhouse-test 02493_max_streams_for_merge_tree_reading ``` Without the fix the test fails with `Resize 4 → 4` instead of `Resize 16 → 32` (same failure shape as CI). With the fix it passes 10/10 runs with the limiter injected and 50/50 runs without it. CI failure example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=bbf2861532b8871fbc0e3d7d3362e1f0e3fabf3f&name_0=NightlyCoverage&name_1=Stateless%20tests%20%28amd_llvm_coverage_per_test%2C%20per_test_coverage%2C%207%2F8%29 PR introducing the regression: ClickHouse#100383 Co-Authored-By: Claude Opus 4.7 <[email protected]>
Pin
read_in_order_two_level_merge_thresholdto prevent the randomized value (0–100) from triggering a two-level merge pipeline when the number of parts exceeds the threshold.Root cause
INSERTwithmax_insert_threads=8creates ~8 parts. Whenread_in_order_two_level_merge_thresholdis randomized below this count (e.g. 6), the read-in-order pipeline switches to a two-level merge structure. Combined withmax_streams_to_max_threads_ratio=8(used in the last test query), the aggregation collapses to 1 thread, eliminating the expectedResize 1 → 4step from the pipeline output.The previous fix (adding
no-parallel-replicastag) addressed a different failure mode but this one persisted — 66+ failures across 30+ unrelated PRs in the last 30 days.Reproduction
Fix
Pin
read_in_order_two_level_merge_threshold = 100before the echo block. This is a targeted fix — only the specific setting that causes the issue is pinned, and the test's intent (verifyingmax_streams_for_merge_tree_readingbehavior) is fully preserved.Verified: 100/100 passes with full randomization locally.
Closes #101657
Changelog category (leave one):
Changelog entry (a]user-readable short description of the changes that goes to CHANGELOG.md):
no changesVersion info
26.4.1.983