Skip to content

Clamp random merge_max_block_size in test 02371_select_projection_normal_agg - #129676

Merged
tiandiwonder merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-slow-02371-merge-max-block-size
Nov 20, 2026
Merged

tiandiwonder merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-slow-02371-merge-max-block-size

Conversation

@groeneai

@groeneai groeneai commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129411

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Clamp the randomized merge_max_block_size to at least 100 in the test 02371_select_projection_normal_agg, which took over 180 s when the runner drew 1.

Description

02371_select_projection_normal_agg took 231 s, over the 180 s limit, in Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted) on #129411 (1 of 50 runs; the others took 10-19 s). That run drew merge_max_block_size = 1, and its two MATERIALIZE PROJECTION statements took 109 s + 112 s.

The INSERT produced a 1,063,188-row part, above the 1,048,449-row default min_insert_block_size_rows that squashes projection input, so p_norm was written as two temporary parts and MergeProjectionPartsTask merged them in blocks of merge_max_block_size rows (Merged sorted, 1063188 blocks, 1063188 rows). The part was Packed, so MATERIALIZE PROJECTION p_agg rebuilt p_norm the same way.

The fix adds -- Random settings limits: merge_max_block_size=(100, None). Only draws below 100 (0.4%) change; the setting stays randomized over [100, 24576], and the data, queries and reference are unchanged.

Validation on ASan: a 1.1M-row MATERIALIZE PROJECTION takes 61-72 s at merge_max_block_size = 1, 2.0 s at 100 and 1.5 s at 8192. Replaying the failing run's settings takes 220-225 s per run, and 12 s with only that value set to 100. A runner forced to draw 1 got 100 in 5/5 runs; with the limits line broken, 1 came back (a 250 s run). 50 randomized runs pass, p_norm is used whenever projections are enabled and the part is not pruned (47/50). In flaky-check mode on master CI binaries (TSan, 32 CPUs, -j 18, 100 runs; ASan, 16 CPUs, -j 8, 50 runs) the max is 59.2 s and 13.1 s.

02516_projections_with_rollup uses the same fixture and is handled in #125496.


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

Version info

  • Merged into: 26.12.1.12-master (included in 26.12 and later)

The test inserts 1,728,000 rows and runs two MATERIALIZE PROJECTION
mutations. When the INSERT produces a part above 1,048,449 rows (the
default min_insert_block_size_rows that squashes projection input), the
p_norm projection is written as two temporary parts, which
MergeProjectionPartsTask merges with a MergeTask that emits blocks of
merge_max_block_size rows. The runner draws that setting from
[1, 24576]; one CI run drew 1 and the projection merge became 1,063,188
one-row blocks (106 s), and since the part was Packed the second
MATERIALIZE rebuilt p_norm the same way. The two ALTERs took 109 s + 112 s
and the run failed "Test runs too long (> 180s)" in
Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted).

Clamp only that setting to [100, 24576] with the per-test limits line,
so the merge stays multi-block and the setting stays randomized.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (2 findings).

# Sev Finding Verdict Evidence / action
1 ⚠️ The amd_msan, flaky check shape was not priced locally (only TSan and ASan were) DISAGREE Last 14 days on master, MSan runs this test at p95 47 s / max 65 s (473 runs), below TSan in every quantile, and the MSan flaky check runs fewer workers (-j 11 vs -j 18) on the same runner type. TSan was priced: max 59.2 s locally.
2 💡 The TSan flaky-mode max (59.2 s) is close to the 60 s stop line set before the runs DISAGREE The stop line was not crossed in two 50-run samples. CI's flaky-mode TSan job for this test: 775 runs in 14 days, max 99.8 s, 0 failures.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261106-042100

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The failing run's exact settings on an ASan server take 220 s and 225 s per run (2/2, same part split as CI, Merged sorted, 1063188 blocks, 1063188 rows), 12 s with only merge_max_block_size set to 100. clickhouse local: a 1.1M-row MATERIALIZE PROJECTION takes 61-72 s at 1 vs 2.0 s at 100.
b Root cause explained? merge_max_block_size = 1 plus an INSERT part above 1,048,449 rows (the projection squash size) gives two temporary p_norm parts, and MergeProjectionPartsTask merges them in one-row blocks (1.06M blocks, ~106 s). The part was Packed, so MATERIALIZE PROJECTION p_agg rebuilt p_norm the same way: two ~110 s ALTERs, 231 s in total.
c Fix matches root cause? Yes: the per-setting limits line removes exactly the draws [1, 99] of the one setting that causes it. No blanket tag, no data or query change, no bound widened.
d Test intent preserved / new tests added? Data, queries and reference are unchanged. p_norm is used in 47/50 (ASan), 97/100 (CI TSan) and 45/50 (CI ASan) runs; the others had projections disabled or an 11-row read. Test-only change, so no new test.
e Both directions demonstrated? A runner forced to draw 1 got 100 in 5/5 runs; with the limits line broken, 1 came back in 2/2 (one run 250 s). Failing settings: 220-225 s vs 12 s with 100.
f Fix is general across code paths? Both MATERIALIZE statements (and any background merge of video_log) go through the one clamped setting. 02516_projections_with_rollup shares the fixture and is handled in #125496.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). 200 randomized runs (ASan, CI TSan, CI ASan) pass.
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? The limit is applied to the randomized MergeTree settings before the client command is built; statements, table settings and the reference are unchanged.

Session id: cron:clickhouse-impl-slot-4:20261106-034800

@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fde82e4]

Summary: ✅


AI Review

Summary

The PR clamps randomized merge_max_block_size to at least 100 in 02371_select_projection_normal_agg to prevent projection materialization timeouts while preserving the test's SQL and assertions. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 6, 2026
@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ, could you review this and add the can be tested label so CI runs? It clamps the randomized merge_max_block_size to at least 100 in this test: at 1, MergeProjectionPartsTask merged the two temporary p_norm parts of a 1.06M-row part one row per block, and the two MATERIALIZE PROJECTION statements took 231 s.

@tiandiwonder tiandiwonder self-assigned this Nov 6, 2026
@clickhouse-gh clickhouse-gh Bot added can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 6, 2026
@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3fe80ab

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Fast test (arm_darwin) / 05495_part_moves_between_shards_step_retry flaky, not in this PR's diff: timeout after MOVE PART ... TO SHARD failed with PART_IS_TEMPORARILY_LOCKED (Part all_0_0_0 does not contain in snapshot of previous virtual parts), the same timeout seen on other unrelated PRs #129409 (mine, open)
Stateless tests (arm_binary, parallel) / 05292_part_log_remove_part_on_retried_drop_table flaky, not in this PR's diff: stderr ASYNC_LOAD_WAIT_FAILED, the table's startup load hit the injected disk_object_storage_fail_commit_metadata_transaction fault; 40 of 40 reruns passed; one other unrelated PR had the same failure on 2026-10-31 a fix task is created (investigating at full effort, fixing-PR link to follow here)
Mergeable Check / PR praktika rollups of the two rows above #129409 (mine, open) and a fix task is created (the owners of the two rows above)

The Config Workflow / Pre Hooks failures in CIDB come from the runs before the can be tested label was added. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261106-080007

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the 05292_part_log_remove_part_on_retried_drop_table failure in Stateless tests (arm_binary, parallel): #129699

@clickhouse-gh clickhouse-gh Bot added comp-projections Projections: precomputed layouts for accelerating queries (projection parts, maintenance). and removed comp-testing Test content only (no production code). labels Nov 19, 2026
@tiandiwonder
tiandiwonder added this pull request to the merge queue Nov 20, 2026
Merged via the queue into ClickHouse:master with commit da3dc32 Nov 20, 2026
386 of 387 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
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 comp-projections Projections: precomputed layouts for accelerating queries (projection parts, maintenance). pr-ci 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.

4 participants