Repository navigation
Backport #116446 to 26.6: Do not use the distributed-plan Shuffle aggregation when bucket order is promised - #120640
Conversation
…regation when bucket order is promised
|
Workflow [BackportPR], commit [00cc675] Summary: ✅ |
|
The only red here is my own new test, and it cannot pass on 26.6 or 26.7. Its first row asserts that the plan text contains SELECT count() > 0 FROM (EXPLAIN PLAN actions = 1, distributed = 1 <query>)
WHERE explain ILIKE '%memory-efficient%';
Minimal adaptation for 26.6 and 26.7: drop that row plus the final @PedroTadim, do you want me to open that against |
`Mode: memory-efficient` is printed by `MergingAggregatedStep::describeActions` only from 26.8 on, so the arming row and the closing boundary row that match `%memory-efficient%` read 0 on this branch and cannot be satisfied there. Both are dropped along with their two reference lines. The guard's own coverage is untouched: the rows asserting that `by hash(` is absent under the bucket-order promise and present without it all pass here. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…order_promise Requested in review on the merged PR ClickHouse#116446: ClickHouse#116446 (comment) The test asserted its plan claims with 12 rows of the form `SELECT count() ... FROM (EXPLAIN ...) WHERE explain ILIKE '%...%'`. Each row projects the plan onto one bit and discards it before the comparison, so a red row prints `1 -> 0` and nothing about the plan, and reading the failure means rebuilding and re-running the explain by hand. The same test is red on the 26.6 backport ClickHouse#120640 right now, with exactly that output. Those 12 rows use only 7 distinct explain queries, differing solely in their `SETTINGS` clause, so they collapse onto 7 pinned plans, each behind a `SELECT '-- label';` marker line so the reference stays navigable. Every `SET` pin and every behavioural row is unchanged: the three `FORMAT Null` rows that must not hit the duplicate-bucket rejection, and the two `HAVING k = 7` result-equality rows. Each block keeps the smallest flag set its claims need. Five are a plain `EXPLAIN`, since the step descriptions they read (`by hash(...)`, `partial`, `merge`) are printed without `actions = 1`. The two asserting the merge mode do need it, because `Mode: memory-efficient` is printed only by `MergingAggregatedStep::describeActions`; those two add `compact = 1`, which makes `skip_expressions` walk past every `Expression` step in the initiator plan and, through `ExplainPlanOptions::toSettingsChanges`, in both shard plans, so their `Actions:`/`Positions:` dumps stay out of the reference. `pretty = 1` is not usable here, as it cannot represent per-shard plans. `index_granularity_bytes = 0` and `min_bytes_for_wide_part = 0` are new in the DDL. The two `actions = 1` plans print `ReadFromMergeTree`'s granule count, and the runner randomizes both of that number's inputs. `index_granularity_bytes` is drawn from `[1024, 30 MiB]` (`tests/clickhouse-test:2006`), and once it falls below `index_granularity` times the row size the adaptive byte quotient replaces the fixed 256 rows per granule: measured on this 16-byte fixture, 2048 prints `Granules: 1563` and 1024 prints 3125, against 782 at 4096 and above. The 100 KiB floor that hides the window applies only to sanitizer, debug and coverage builds (`:2096-2103`), so a release-flavour run is the exposed one. `min_bytes_for_wide_part` moves the same number by one between the two part formats. With adaptive sizing off the count is `ceil(rows / index_granularity)` for any block width and either format, which also closes the row-width exposure through the randomized `enable_block_number_column` and `enable_block_offset_column`. A table setting in the DDL holds against the runner's injection, which skips settings the query already sets, and against the server default alike, which is why the `index_granularity = 256` this reference also depends on already survives there. Validation: removing the guard hunk ClickHouse#116446 added at `makeDistributed.cpp:715-721` makes 4 of the 7 blocks red, with `ShuffleExchange (by hash([__table1.k]))` reappearing once per shard plan, while the 3 blocks asserting that the shuffle stays when nothing promises bucket order are byte-identical; the reference reds on that regression and only there. The granule pins are proven through the runner's own merge-tree injection seam: `--merge-tree-settings "--index_granularity_bytes 2048"` passes with them and reds `Granules: 782 -> 1563` on all four lines without them. 50 of 50 runs green with settings randomization on (161-196 settings drawn per query, 50 distinct randomized merge-tree tails, part format Wide in all 50). The reference is generated from the runner's own stdout, not pasted by hand. Co-Authored-By: Claude Opus 5 <[email protected]>
Original pull-request #116446
Cherry-pick pull-request #120637
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.
The PR source
The PR is created in the CI job
Version info
26.6.9.15