Repository navigation
Fix server abort on GROUPING SETS in a set operation with parallel replicas - #109003
Conversation
…plicas A UNION ALL or INTERSECT/EXCEPT where one branch uses GROUP BY GROUPING SETS over a parallel-replicas read and another branch uses FINAL aborted the server in the non-analyzer interpreter with a LOGICAL_ERROR "Cannot find __grouping_set column in header of MergingAggregatedTransform with grouping sets" (or "Chunk info was not set for chunk in MergingAggregatedTransform"). Set-operation branches were built with a shared mutable context. The FINAL branch disables parallel replicas for itself (allow_experimental_parallel_reading_from_replicas = 0), which retroactively changed the grouping-sets branch's already chosen processing stage: it had picked WithMergeableState and a MergingAggregatedStep with grouping sets, but its read then fell back to a local read whose header lacks the synthetic __grouping_set column. Build each set-operation branch with its own context copy so a branch's settings changes cannot leak into a sibling branch. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-4:20260630-224900 |
|
cc @KochetovNicolai @nickitat — could you review this? It fixes a non-analyzer server abort where set-operation branches share a mutable context: a FINAL branch disables parallel replicas for itself, retroactively breaking a sibling GROUPING SETS branch that had already chosen WithMergeableState and a MergingAggregatedStep, leaving its input header without |
|
Workflow [PR], commit [a1aa2ce] Summary: ✅
AI ReviewSummary
Missing context / blind spots
Final Verdict
|
…rations When a set operation is planned as a column-pruned subquery (non-empty required_result_column_names), the constructor first probes each child header via getCurrentChildResultHeader. The probe instantiated the temporary child interpreters with the union's mutable parent context, so a FINAL child that disables allow_experimental_parallel_reading_from_replicas leaked that change into the parent context. The real (copied-context) children built afterwards then inherited parallel replicas already disabled, so a sibling grouping-sets branch silently lost parallel replicas. Give the probe the same per-child Context::createCopy as the real construction path so column-pruned subqueries keep the same branch-local settings scope as top-level set operations. Extend the regression test with a pruned-subquery case asserting the grouping-sets branch still reads with parallel replicas. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Follow-up fix for the AI-review finding on the column-pruned-subquery path (commit f17f302). Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-4:20260701-031100 |
…terministic The pruned-subquery case added for the header-probe fix asserts that the grouping-sets branch reads with parallel replicas (ParallelReplicasUsedCount > 0). The CI flaky check randomizes automatic_parallel_replicas_mode to 2 in ~25% of runs. With the old analyzer (enable_analyzer = 0), a non-zero automatic_parallel_replicas_mode is unsupported, so InterpreterSelectQuery resets allow_experimental_parallel_reading_from_replicas to 0 and no parallel replicas are used, flipping the assertion to "pr NOT used". Pin the setting to 0 in the test's settings block so the injected value is overridden and the assertion holds under randomization, without touching the grouping-sets coverage. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Fixed the PR-caused flaky-check failure on the newly-added pruned-subquery case ( Root cause. The pruned-subquery case asserts the grouping-sets branch reads with parallel replicas ( Fix. Pin Reports:
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260701-044600 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 20/21 (95.24%) · Uncovered code |
CI finish ledger — a1aa2ceEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
All real CI is green on this head. Finish Workflow and Mergeable Check both pass; the 4 flaky-check lanes (amd_debug / amd_asan_ubsan / amd_tsan / amd_msan) now pass 56/56 after the pruned-subquery Session id: cron:our-pr-ci-monitor:20260701-090000 |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Thanks, that's clear.
…o-read-setting
The branch was ~11.7k commits behind (last merge 2026-06-20) and red. The
diff vs. `master` is still the single randomizer line — no functional change:
"parallel_replicas_min_number_of_rows_per_replica": lambda: random.randint(0, 1),
Reason to re-merge now: the parallel-replicas owners have landed several
directly relevant fixes since 2026-06-20, so refreshing CI on today's
`master` will narrow the remaining set of genuine product bugs this PR is
meant to surface:
- #108451 (`Fix NOT_FOUND_COLUMN_IN_BLOCK for virtual columns under parallel
replicas`, closes #106561) — should clear the tracked
`04098_asterisk_include_virtual_columns_mergetree` failure.
- #101434 (`Reimplement reading in order for parallel replicas`) — bears
directly on the `max_rows_to_read`-not-honored class
(`02155_read_in_order_max_rows_to_read`, `00945_bloom_filter_index`).
- #109003 (`Fix server abort on GROUPING SETS in a set operation with
parallel replicas`) — a "Server died" class fix.
- Flaky-test fix for `04051_pk_analysis_stats`.
Conflicts were all in files the branch does not intentionally change (its
only intended change is the one `tests/clickhouse-test` line); they were
resolved by taking `master`'s version. No pinning/blacklisting of the
affected parallel-replicas tests — that would mask the very signal this PR
exists to produce.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…merging-aggregated-grouping-set Fix server abort on GROUPING SETS in a set operation with parallel replicas
Related: #107826
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERROR("Cannot find__grouping_setcolumn in header of MergingAggregatedTransform with grouping sets", or "Chunk info was not set for chunk in MergingAggregatedTransform") that could occur, without the analyzer, for aUNION ALL/INTERSECT/EXCEPTwhere one branch usesGROUP BY GROUPING SETSwith parallel replicas and another branch usesFINAL.Description
Found by the AST fuzzer on #107826 (
AST fuzzer (amd_tsan), report, STID 5710-675a). The fuzzed query is a server-sideGROUPING SETSplanning bug unrelated to that PR's Web-UI/docs change.Reproducer
Root cause
InterpreterSelectWithUnionQueryandInterpreterSelectIntersectExceptQuerybuild all of their branch interpreters with the same mutable context. Both branch interpreters are constructed first, then planned.getQueryProcessingStagereturnsWithMergeableStateand the branch caches that as itsfrom_stage. Its plan therefore adds aMergingAggregatedStepwith grouping sets, whose input is expected to carry the synthetic__grouping_setcolumn produced by the partial-aggregation read on the replicas.FINALbranch is constructed next and, becauseFINALis not supported with parallel replicas, setsallow_experimental_parallel_reading_from_replicas = 0on the shared context.from_stagestill saysWithMergeableState, but the read now falls back to a local read (parallel replicas were disabled in the shared context) whose header has only the grouping key, without__grouping_set. TheMergingAggregatedStepthen sees grouping sets but no__grouping_setand the transform raises aLOGICAL_ERROR(the same divergence also produces "Chunk info was not set ..." when there are no grouping sets).The analyzer is not affected: it decides parallel replicas and the processing stage per branch at planning time.
Fix
Build each set-operation branch with its own context copy (
Context::createCopy), so a branch disabling parallel replicas for itself can no longer retroactively change a sibling branch's already chosen processing stage. This matches how the analyzer keeps the branches independent.Verified both directions on a debug build (server aborts before the fix, passes after) and added a regression test
04492_grouping_sets_parallel_replicas_set_operation_final.Version info
26.7.1.372(included in26.7and later)