Skip to content

Keep the overflow arms of 04896_orfill_merge_group_by_overflow_any off parallel replicas - #123679

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04896-orfill-parallel-replicas
Oct 3, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04896-orfill-parallel-replicas

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122853
Related: #114740

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

04896_orfill_merge_group_by_overflow_any fails in the new Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) job from #122853: the overflow any two keys arm prints 2000 0 instead of 1000 0 (report).

The group_by_overflow_mode = 'any' arms assert an exact surviving-key count, 1000, which holds only when one aggregation stream reads the three projection parts and freezes its hash table after the first. With parallel replicas each replica applies max_rows_to_group_by to its own stream ("for distributed query processing, restrictions are applied on each server separately", query-complexity.mdx), and the initiator's final merge does not apply the limit. So the count is 1000 times the number of replicas that got a part, which depends on which replicas announce before the parts are assigned. The values stay exact (the second column is 0 in every run); only the key count depends on the topology.

The five any arms now pin enable_parallel_replicas = 0 next to their other pins. The null-place merge they cover (#114740) does not depend on how parts are spread over replicas. no overflow, overflow throw and the EXPLAIN arm keep running under parallel replicas.

Validation: a local three-replica cluster with the slowdown_parallel_replicas_local_plan_read failpoint and concurrent load reproduces the 2000 0 diff (about 5% of loop iterations, 1/50 runner runs). With the change the test passes 50/50 there, and 50/50 with randomized settings in the regular configuration.

If you prefer to keep the whole test out of this job, I can use the no-parallel-replicas tag instead.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/123679]

Version info

  • Merged into: 26.10.1.1418-master (included in 26.10 and later)

…f parallel replicas

The group_by_overflow_mode = 'any' arms assert an exact surviving-key count
(1000), which holds only when one aggregation stream reads the three
projection parts and freezes its hash table after the first one.

Under parallel replicas (the new `Stateless tests (arm_binary,
ParallelReplicas, s3 storage, parallel)` job from ClickHouse#122853) each replica's
AggregatingStep applies max_rows_to_group_by to its own stream, and the
initiator's MergingAggregatedStep is built with the merge-only
Aggregator::Params, which carry no max_rows_to_group_by. So every replica
that reads at least one part keeps that part's 1000 keys, and the count is
1000 x (replicas that read a part). Which replica reads which part depends
on announcement timing in ParallelReplicasReadingCoordinator. This is the
documented per-server limit ("for distributed query processing, restrictions
are applied on each server separately"); the values stay exact, only the key
count depends on the topology. Seen on PR ClickHouse#118272: `overflow any two keys`
printed 2000 instead of 1000.

Pin enable_parallel_replicas = 0 in the outer SETTINGS of the five `any`
arms, next to the other pins that hold the topology the counts encode. The
null-place merge these arms cover (ClickHouse#114740) does not depend on replica
distribution. The `no overflow`, `overflow throw` and EXPLAIN arms are
topology-independent and keep running under parallel replicas. The pin also
covers AutoParallelReplicas, since automatic_parallel_replicas_mode requires
enable_parallel_replicas != 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 Header comment "these arms" also reads as covering overflow throw, which is not pinned AGREE noted, not blocking
2 💡 "the final merge does not apply the limit" holds on the default parallel-replicas path; with parallel_replicas_plan_based = 1 the initiator merge keeps max_rows_to_group_by AGREE noted, not blocking: the pin disables both paths

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261003-102900

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? On a local three-replica cluster with the slowdown_parallel_replicas_local_plan_read failpoint and concurrent loops: the unfixed test prints overflow any two keys 2000 0 in 199 of 3805 iterations, 1/50 runner runs. The trigger is replica announcement timing, which no setting forces.
b Root cause explained? Each replica applies max_rows_to_group_by to its own stream and the initiator's MergingAggregated applies no limit, so the count is 1000 per replica that read a part. Documented per-server semantics; the values stay exact.
c Fix matches root cause? Yes: the five arms whose oracle encodes the single-server topology pin enable_parallel_replicas = 0 in their outer SETTINGS. No widened bound, no blanket tag.
d Test intent preserved / new tests added? Yes: the null-place merge (#114740) still runs on one server with the same exact counts as its coverage guard; no overflow, overflow throw and the EXPLAIN arm keep running under parallel replicas. Test-only change, .reference unchanged.
e Both directions demonstrated? Same server state: fixed 100/100 byte-identical to .reference while the unfixed file flipped 43/601. Runner, ParallelReplicas profile: fixed 50/50 OK, unfixed 1/50 FAIL with the CI diff. Regular configuration, randomized: fixed 50/50 OK.
f Fix is general across code paths? All five any arms are pinned; throw and no overflow are split-independent. Covers AutoParallelReplicas too (it requires enable_parallel_replicas != 0).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only change).
h Backward compatible? (maintainer-approved exception only) N/A (no setting, format or engine change).
i Invariants and contracts preserved? N/A for engine code; the test's own invariant (exact count only on one stream reading all three parts) now holds in every CI configuration.

Session id: cron:clickhouse-impl-slot-4:20261003-100500

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f720c6e]

Summary: ✅


AI Review

Summary

This PR makes 04896_orfill_merge_group_by_overflow_any deterministic under the ParallelReplicas job by pinning enable_parallel_replicas = 0 only on the five group_by_overflow_mode = 'any' queries whose oracle depends on a single aggregation stream. The change matches the failure mode described in the PR, keeps the unaffected no overflow, overflow throw, and EXPLAIN coverage under parallel replicas, and I do not see a remaining correctness or coverage gap in the current diff.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 3, 2026
@groeneai
groeneai requested a review from nickitat October 3, 2026 10:54
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 3, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 3, 2026
Merged via the queue into ClickHouse:master with commit bf5e53d Oct 3, 2026
160 of 161 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 3, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 3, 2026
Picks up ClickHouse#123679, which fixes the 04896_orfill_merge_group_by_overflow_any
failure in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel).
@clickhouse-gh clickhouse-gh Bot added comp-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants