Repository navigation
Pin the adaptive aggregator freeze threshold in 05234_query_plan_aggregation_having_prefilter_results - #123653
Conversation
…g_prefilter_results
The statistics cells of the test failed in `Stateless tests (amd_debug, distributed plan,
s3 storage, parallel)` with `05234ap_on 0` instead of 20000, and on reruns with
`Code: 395 ... boom` from the `throwIf` cell (client rc 139 = 395 & 0xFF), under
`--index_granularity 1652`.
On a remote disk `merge_tree_min_{rows,bytes}_for_concurrent_read_for_remote_filesystem`
default to 0, so min marks per read task is `merge_tree_min_read_task_size` = 8 and the
61 marks of `having_prefilter_wide` at that granularity are read in 8 streams. More than
one stream admits the adaptive aggregator, and each thread holds about 12500 keys, under
`adaptive_aggregator_freeze_threshold` (16384). A table in the learning phase skips the
two-level conversion, and with no freeze in the session the finish step does not convert
either, so every table ends single-level despite `group_by_two_level_threshold*` and
`max_bytes_before_external_group_by`. The HAVING pre-filter is honoured only in the
two-level bucket conversion, so nothing is skipped and the `throwIf` conjunct sees the
rejected groups. A thread that happens to cross the threshold (work stealing) freezes a
table and rescues the run, which is why it is frequent rather than certain on s3.
Pinning `enable_adaptive_aggregator = 0` removes the one unpinned gate on the path the
cells measure, so they run on the two-level conversion for any read split, multi-stream
reads included. The reference is unchanged.
Measured on a debug build, same binary for both arms: local disk forced to the remote
split (61 marks, 8 streams) 20/20 fail before and 0/20 after; with the freeze threshold
out of reach 20/20 and 0/20, and the fix without the new SET fails 20/20; an s3-backed
server with only index_granularity 1652 and 4 runs in parallel 29/40 and 0/40. Every
failing run froze no table, every passing base run froze one. 50/50 randomized runs pass
on local disk and on s3.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding), plus my own review of the diff (no blocker or major finding).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261003-052200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261003-045600 |
|
Workflow [PR], commit [b4444e7] Summary: ✅ AI ReviewSummaryThis PR updates Final Verdict
|
Disabling `enable_adaptive_aggregator` for the file kept the statistics cells stable, but it also took the HAVING pre-filter off the adaptive `GROUP BY` path, which multi-stream reads of the fixtures (remote disks, small `index_granularity`) are the only cells to reach. `adaptive_aggregator_freeze_threshold = 0` keeps that path and makes it deterministic: every adaptive table freezes on its first block, so the session converts to two-level at the finish and the pre-filter acts, exactly as when a table crosses the threshold on its own. Measured on the same debug build: local disk forced to 8 streams, 0/30 fail with 8 tables frozen and 20000 groups skipped on every run, 0/100 with 4 copies in parallel, 0/30 with the freeze threshold set out of reach on the client; the pre-fix file fails 10/10 there. s3-backed server with `index_granularity = 1652`, 4 copies in parallel: 14/40 fail before, 0/80 after, 7 tables frozen per run. Randomized runs pass on local disk (45/45), with the concurrent-read thresholds forced to 1 (64/64, 6 on the adaptive path) and on s3 (53/53, 10 on the adaptive path). With the freeze pin, the result cells on a multi-stream read now also compare answers with the pre-filter skipping groups on the adaptive path, where they previously compared two runs that skipped none. Also wrap `AggregatingStep::transformPipeline` in the comment above as inline code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
05234_query_plan_aggregation_having_prefilter_results05234_query_plan_aggregation_having_prefilter_results
Related: #120510
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Test-only change, no changelog entry required.
Description
The test I added in #120510 failed in
Stateless tests (amd_debug, distributed plan, s3 storage, parallel)with05234ap_on 0instead of20000, and on the runner's reruns withCode: 395 ... boomfrom thethrowIfcell.The runner's diagnosis named
--index_granularity 1652:https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118242&sha=4155fc96c5f98a316def85a946ff9fd6a885315d&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29
On a remote disk the concurrent-read thresholds default to 0, so the 61 marks of the 100000-row fixture are read in
8 streams. That admits the adaptive aggregator, and each thread holds about 12500 keys, under its 16384-key freeze
threshold. A table that never freezes skips the two-level conversion, so the final merge is single-level and the
HAVING pre-filter, which acts only in the two-level bucket conversion, never runs. The file's two-level pins do not
cover that gate. In the failing job's
query_log, all 96 reruns at 61 marks froze no table.The test now sets
adaptive_aggregator_freeze_threshold = 0next to the other pins. Every adaptive table thenfreezes on its first block, so the pre-filter acts on the adaptive path too, whatever the read split. The reference
is unchanged.
Validation, debug build, same binary for both arms:
run); 0/100 with 4 copies in parallel; 0/30 with the freeze threshold set out of reach on the client.
index_granularity = 1652, 4 copies in parallel: 14/40 fail before, 0/80 after.(53/53); 16 of them took the adaptive path.
Workflow [PR]
Sync PR [sync-upstream/pr/123653]
Version info
26.10.1.1403-master(included in26.10and later)