Skip to content

Remove the order-dependent groupArray statement from test 04651_nullable_tuple_lowcardinality_subcolumn_shared_cache - #124956

Merged
CurtizJ merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04651-parallel-replicas-order
Oct 10, 2026
Merged

CurtizJ merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-04651-parallel-replicas-order

Conversation

@groeneai

@groeneai groeneai commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #112232

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

04651_nullable_tuple_lowcardinality_subcolumn_shared_cache fails in the ParallelReplicas lanes on one statement, SELECT groupArray(x.a) FROM (SELECT x.a.b, x.a FROM t_04651_ranges SETTINGS max_block_size = 2), which returns the same 20 values rotated, e.g. on #122506: report. The coverage lane relabels such failures OK: 59 identical diffs in 30 days over ~10,600 ParallelReplicas runs, including master (bd202925d0d4), and none in other lanes or on other lines.

The table is ORDER BY tuple() and the query has no ORDER BY. Under parallel replicas each replica builds a partial groupArray state over the mark ranges it was given, and the initiator merges the states in arrival order. The failing output is exactly marks 3..9 followed by marks 0..2.

The statement also does not exercise the bug the test was added for in #112232 (a child and its parent subcolumn read together from one Compact part): the analyzer drops the unused x.a.b from the subquery, and EXPLAIN actions = 1 shows ReadFromMergeTree with Output: x.a only. The previous statement reads x.a, x.a.b across granule ranges with order-independent aggregates, so it keeps that coverage. The change deletes the statement and its two reference lines.

Validation: the test passes 50/50 randomized runs on a default server and 100/100 on a local ParallelReplicas-config server (50 of them with parallel_replicas_local_plan = 0).


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

Version info

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

The statement asserted the exact order of `groupArray` over a table with
`ORDER BY tuple()` and no `ORDER BY` in the query. Under parallel replicas
each replica aggregates the mark ranges it was given and the initiator
merges the partial states in arrival order, so the array came back rotated
when the part was split between replicas (marks 3..9 before marks 0..2).

It also did not exercise the bug the test covers: the analyzer prunes the
unused `x.a.b` from the subquery, so only `x.a` was read. The child and
parent read across several granule ranges stays covered by the previous
statement, whose aggregates do not depend on the order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Oct 9, 2026
@groeneai

groeneai commented Oct 9, 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 (0 findings).

# Sev Finding Verdict Evidence / action
- - none - Checked: the analyzer pass that prunes the subquery's unused x.a.b is not gated by any setting, so the deleted statement never read the child; the remaining statement reads x.a, x.a.b with order-independent aggregates; every ParallelReplicas-lane diff of this test in 30 days is on the deleted statement.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-11:20261009-163600

@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The 59 CI diffs are byte-identical, and the failing array is exactly the two per-range groupArray results concatenated in the other order (marks 3..9, then 0..2), reproduced deterministically with clickhouse local. A local ParallelReplicas rig never split the read (20,000 runs, one replica used), so the split itself is shown by CIDB only.
b Root cause explained? Unordered groupArray over an ORDER BY tuple() table; under parallel replicas each replica builds a partial state and the initiator merges states in arrival order, which rotates the array when the part is split.
c Fix matches root cause? Yes: the order-dependent statement is removed. It read only x.a (EXPLAIN actions = 1: Output: x.a), so it never covered the bug the test is for.
d Test intent preserved / new tests added? Yes: the previous statement still reads x.a, x.a.b together across granule ranges with order-independent aggregates.
e Both directions demonstrated? Failing: 59 CIDB occurrences of the rotated array (incl. master). Passing: 50/50 randomized on a default server, 100/100 on a ParallelReplicas-config server (50 with parallel_replicas_local_plan = 0).
f Fix is general across code paths? The other statements read 4-row parts or use ORDER BY id; none of the 59 diffs touches them.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only change).
h Backward compatible? (maintainer-approved exception only) N/A (no setting or source change).
i Invariants and contracts preserved? N/A (no source change).

Session id: cron:clickhouse-impl-slot-6:20261009-161000

@groeneai
groeneai requested a review from CurtizJ October 9, 2026 16:55
@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [784f252]

Summary: ✅


AI Review

Summary

This PR removes an order-dependent groupArray(x.a) assertion from 04651_nullable_tuple_lowcardinality_subcolumn_shared_cache, a stateless test added by #112232. I did not find a correctness issue with the change: the deleted query is inherently unstable under ParallelReplicas because it aggregates rows from an ORDER BY tuple() table without an ORDER BY, and the remaining range test still reads both x.a.b and x.a together with order-independent checks, so the intended regression coverage is preserved.

Final Verdict

Status: ✅ Approve

@CurtizJ
CurtizJ enabled auto-merge October 10, 2026 13:39
@CurtizJ
CurtizJ added this pull request to the merge queue Oct 10, 2026
Merged via the queue into ClickHouse:master with commit 0023365 Oct 10, 2026
163 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 10, 2026
@clickhouse-gh clickhouse-gh Bot added comp-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... 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-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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