Repository navigation
Pin merge_max_block_size in 05210_skip_index_type_from_alter_session_setting - #121126
PedroTadim merged 2 commits into
Conversation
…setting `05210_skip_index_type_from_alter_session_setting` asserts an exact granule count, `LIKE '%Granules: 16/32%'`, on the part left by `OPTIMIZE FINAL`: 128 rows at `index_granularity = 4` is 32 granules, and `idx` prunes the 16 that do not hold `v = 1`. The table pins `index_granularity` and `index_granularity_bytes` for exactly that reason, but not `merge_max_block_size`, which the stateless runner randomizes from `random.randint(1, 8192 * 3)` (`tests/clickhouse-test:2015`). `merge_max_block_size` bounds the rows per merge output block, and the Compact part writer computes granularity per written block, `computeIndexGranularity(result_block)` at `MergeTreeDataPartWriterCompact.cpp:257`. In `fillIndexGranularityImpl` (`:501-510`) a block tail shorter than a full granule gets its own short mark when `rows_left_in_block * 2 >= index_granularity_for_block`, which the comment at `:507` describes as deliberate, and `getGranulesToWrite` then reports that short granule as complete, so the next block starts a fresh mark instead of filling it. At `merge_max_block_size = 110` the merge emits 110 + 18 rows and writes 33 marks rather than 32, `v = 1` starts at mark 16, and the plan prints `Granules: 17/33`. The literal stops matching and the assertion returns 0. ClickHouse is correct at that value, and the invariant the test was added for holds: the merge does not throw in `MergeTreeIndexAggregatorSet::update`, `force_data_skipping_indices = 'idx'` raises no `INDEX_NOT_USED`, both counts are still 64, and `idx` still prunes about half the granules. Only the exact-count literal moved, so the fix belongs in the fixture. Pinning the setting in the table's own `SETTINGS` clause is enforced rather than best-effort: `ClientBase::addMergeTreeSettings` injects a randomized MergeTree setting only when the clause does not already carry that name, `if (!storage_settings.changes.tryGet(change.name))` at `src/Client/ClientBase.cpp:3953`. Measured under the runner's own injection form, a pinned table records `merge_max_block_size = 8192` while an unpinned one records the injected 110. `8192` is the setting's own default (`MergeTreeSettings.cpp:483`), so the test keeps running the configuration it has passed 832 times under, and `.reference` is unchanged. Measured over 14 values of `merge_max_block_size` from 1 to 8192: the 7 the writer model predicts will break (3, 5, 7, 23, 63, 110, 127) all fail without the pin and all pass with it, and the 7 it predicts are safe (1, 2, 4, 64, 100, 128, 8192) give `16/32` either way. A negative control that keeps the added comment and reverts only the pin brings the failure back. 50 randomized runs pass, with randomization confirmed live in `system.query_log`. The pin is also sufficient for Wide parts and for vertical merges; the short-mark branch is Compact-specific, since the Wide writer carries a partial mark across blocks through `rows_written_in_last_mark` and gives `16/32` even at 110. A `-- Random settings limits:` clamp was rejected. It is parsed out of a comment and so fails silently when mistyped, it bounds only the random draw rather than the table's own layout contract, and the conventional `merge_max_block_size=(100, None)` floor used by 12 in-tree tests would not have excluded the drawn 110, which measuring 100 as a good value confirms. 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; 0 findings), plus my own cold
Severity: ❌ blocker / The obvious question on a pin like this is whether it hides a real bug, so I checked that Session id: cron:clickhouse-review-slot-9:20260920-020700 |
|
Workflow [PR], commit [75115b0] Summary: ✅ AI ReviewSummaryThis PR pins Missing context / blind spots
Final Verdict✅ No findings. |
CI finish ledger - 2393163Every 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
Not caused by this PR: the diff is one line in Session id: cron:our-pr-ci-monitor:20260920-100125 |
|
Fixing PR for the |
The final listing ordered by `event_time_microseconds`, which holds the statement's start time on a `QueryStart` row and its end time on a `QueryFinish` row. The committed reference is statement order, so that key reproduced it only while every finish timestamp compared strictly less than the next statement's start timestamp. Those are two independent clock reads and the only margin between them is one client round trip, so when the margin collapsed the sort was free to emit the other permutation, which is what the failure below shows: identical content, two adjacent rows transposed. `script_query_number` is the client's 1-based statement counter and the QueryFinish log element is a copy of the QueryStart one, so both rows of a statement carry the same value and `type` separates them. In this result set `(script_query_number, type)` is unique per row, so the listing is ordered without reading a clock at all. The reference is unchanged, which is the cheapest proof the ordering semantics were preserved rather than redefined. Failure this fixes, Fast test (arm_darwin): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121126&sha=239316397592d4fd59cfac529b039ba88282c3be&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 ClickHouse#121126
Pulls in #121126, which pins `merge_max_block_size` in `05210_skip_index_type_from_alter_session_setting`, the only red of the previous CI run. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Related: #119799
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
05210_skip_index_type_from_alter_session_settingfailed once on master inStateless tests (amd_tsan, parallel)(report): the first assertion flipped1to0, and the runner's minimization isolated--merge_max_block_size 110(52/52 reproducible).Root cause. The test asserts an exact
Granules: 16/32on the merged part. A merge computes index granularity per output block (MergeTreeDataPartWriterCompact.cpp:257), and a block tail shorter than a full granule gets its own short mark (:501-510, deliberate per the comment at:507). At 110 the 128-row merge emits 110 + 18 and writes 33 marks instead of 32, so the plan printsGranules: 17/33.merge_max_block_sizeis randomized, and was the one block-splitting setting not pinned besideindex_granularityandindex_granularity_bytes.Not a server bug. At 110 the merge does not throw,
force_data_skipping_indices = 'idx'raises noINDEX_NOT_USED, both counts are still 64, andidxstill prunes half the granules. Only the exact-count literal moved; the invariant #119799 added this test for is intact.The change pins
merge_max_block_size = 8192, the setting's own default, in the table'sSETTINGSclause;.referenceand the assertion are unchanged. It is enforced, not best-effort: the client only injects a randomized MergeTree setting the clause does not already carry (ClientBase.cpp:3953). 49 other stateless tests pin it the same way.Validation. Deterministic FAIL at 110 before, OK after; reverting only the pin brings the failure back. Swept 14 values from 1 to 8192 including all 7 predicted to break: green with the pin. 50/50 green, randomization confirmed live; the pin also suffices for Wide parts and vertical merges. CIDB: 832 passes against this one failure over 30 days, zero PR carriers.
7 other stateless tests assert an exact granule count after a merge without this pin; they measure 583k+ runs with zero master failures in the window, so I left them alone. Happy to extend the pin on request.
CIDB query and result (30 days, measured 2026-09-20)
The single failing row:
Stateless tests (amd_tsan, parallel),2026-09-19 23:37:18,ee32c21d2f6541c526f6d7fcef5062406aad7bd5,head_ref = master,pull_request_number = 0.Workflow [PR]
Sync PR [sync-upstream/pr/121126]
Version info
26.10.1.419-master(included in26.10and later)