Repository navigation
Clamp the randomized index granularity in 01780_column_sparse_alter - #120968
Conversation
Stateless tests (amd_binary, flaky check) on ClickHouse#119686 failed this test at 208.35 s against the 180 s cap (TEST_MAX_RUN_TIME_IN_SECONDS, tests/clickhouse-test:214, enforced at :3770-3775). The test is untouched by that PR; the flaky check matches test names by prefix, so a change to 01780_column_sparse.sql selects 01780_column_sparse_alter too and runs it 50 times, each with a fresh randomized settings draw. That draw was index_granularity 1. With index_granularity_bytes 17728586 (never binding) and min_bytes_for_wide_part 1073741824 (so the part is Compact), the 2000-row INSERT produced one part with 2001 marks. SET mutations_sync = 2 then makes each ALTER wait for a mutation that rewrites the whole part one granule at a time, so every per-chunk fixed cost is paid 2000 times. From the failing job's own part_log: DROP COLUMN + RENAME took 82 990 ms (Seek 2002, CompressedReadBufferBlocks 4000) and MODIFY COLUMN 103 184 ms (Seek 2003, FunctionExecute 2000, RWLockAcquiredReadLocks 2000), with the three uniqExact reads adding 16 770 ms. CPU is a small fraction of that wall time and MutatePartStart is logged in the same second as the ALTER, so this is neither data volume nor scheduling delay. Speeding the test up is not available: in the other 49 draws of the same batch no single statement exceeded 1.31 s, so there is no slow step. The granule count is the variable, and unlike the row count (an oracle input, via the 1-in-11 and 1-in-13 densities behind the reference counts 182 and 155) it is purely a randomizer artefact. So bound the two settings that set granule size instead. clickhouse-test already applies exactly these two bounds, for exactly this reason, at tests/clickhouse-test:2101-2103, but only on sanitizer, debug and coverage builds; amd_binary is none of those, so randint(1, 65536) applied in full. This test opts into the same bound rather than widening the global one. index_granularity_bytes is clamped as well because adaptive granularity takes the minimum of the two, so a low byte draw shrinks granules even at index_granularity 100: measured, 1024 gives 49 marks against 21 at 100000. Coverage is kept. index_granularity still ranges over [100, 65536], i.e. 1 to 20 granules over 2000 rows, so multi-granule sparse serialization is still exercised, and the assertions are untouched: the Sparse kind is chosen once per part at INSERT in MergeTreeDataWriter::writeTempPartImpl (choose_kind = true) and the mutations inherit it (MutateTask.cpp, choose_kind = false), while index_granularity affects only mark layout. The test's output is byte-identical to the reference at index_granularity 1, 100 and 8192, and with index_granularity_bytes 1024 and 100000. Validated through the runner with 6000 randomized runs per arm: without this line 7 runs produced granules below 100 rows (worst 5 rows, 400 marks), with it none did and the worst run sits on the intended floor of 20 marks. The directive itself fails silently when unparsed, so it was also checked against the real parser and randomizer over 20000 draws, with a negative control that corrupts one character of the prefix and brings sub-100 draws back (25 of 20000, minimum 1). The seven sibling 01780_column_sparse* tests are subject to the same randomizer but show no too-long failure in 30 days of CIDB, so they are left alone. Asked for in ClickHouse#119686 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 gate finding and 5 reviewer nits, the
Severity: blocker / major / nit. DISAGREE verdicts carry recorded evidence and are terminal per finding. Session id: cron:clickhouse-review-slot-9:20260919-033900 |
|
Workflow [PR], commit [1dab0eb] Summary: ✅ AI ReviewSummaryThis PR adds a Final Verdict
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260919-030500 |
e4dac56
Related: #119686
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Bounded the randomized
index_granularityandindex_granularity_bytesin01780_column_sparse_alterso it no longer times out in the flaky check.Description
Asked for in #119686 (comment): "make
01780_column_sparse_alterfaster (or pin its granularity) so it stops timing out under randomized MergeTree settings."Stateless tests (amd_binary, flaky check)on #119686 failed it at 208.35 s against the 180 s cap. The test is untouched by that PR; the flaky check matches by prefix, so01780_column_sparseselects it too.Root cause, from that job's own
query_logandpart_log: the draw wasindex_granularity 1, so the 2000-row Compact part carried 2001 marks, andmutations_sync = 2waited on two whole-part mutations paying a per-granule cost 2000 times, 82.99 s (Seek 2002) and 103.33 s (FunctionExecute 2000), plus 16.8 s of granule-bound reads. In the batch's other 49 draws no statement exceeded 1.31 s, so there is no slow step: the granule count is the variable, and a pure randomizer artefact.clickhouse-testalready applies these two bounds for this reason, but only on sanitizer, debug and coverage builds (tests/clickhouse-test:2101).amd_binaryis none of those, so the full range applied; this test opts into the same bound rather than widening the global one. The byte bound matters too: adaptive granularity takes the minimum, so 1024 bytes gives 49 marks atindex_granularity100, against 21 at 100000.Validation through the runner, 6000 randomized runs per arm: without the line, 7 runs drew granules below 100 rows (worst 5 rows, 400 marks); with it none did, and the worst sits on the intended 20-mark floor. Output is byte-identical to the reference at
index_granularity1, 100 and 8192, so theserialization_kindoracle is unaffected: the Sparse kind is chosen once per part at INSERT and the mutations inherit it, and the floor still leaves up to 20 granules. The seven sibling01780_column_sparse*tests show no such failure in 30 days of CIDB and are left alone.Workflow [PR]
Sync PR [sync-upstream/pr/120968]
Version info
26.10.1.195(included in26.10and later)