Skip to content

Make 00956_join_use_nulls_with_array_column deterministic - #125133

Merged
alexey-milovidov merged 4 commits into
masterfrom
fix/flaky-00956-join-use-nulls-order
Oct 13, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
fix/flaky-00956-join-use-nulls-order

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Since the left side of the join in 00956_join_use_nulls_with_array_column became numbers(10) (8182000), the ANY LEFT JOIN ... LIMIT 1 query has no ORDER BY, so it may return any of the left rows. With parallel replicas it returned 5 instead of 0:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125010&sha=7bb4fa863a77f8bfe9065f40349fdab1db9bea39&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29

This makes every query independent of the row order while LIMIT stays directly on the join result: the SEMI LEFT JOIN keeps only the single matching row, one ANY LEFT JOIN has only unmatched rows (so the Array column is always the default []), and another ANY LEFT JOIN takes all rows, mixing matched and unmatched ones, and counts them.

Related: #125010

Changelog category (leave one):

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

🤖 Generated with Claude Code


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

Version info

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

@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [59cf6f3]

Summary: ✅


AI Review

Summary

This PR makes 00956_join_use_nulls_with_array_column deterministic under ParallelReplicas by replacing the flaky mixed-row ANY LEFT JOIN ... LIMIT 1 assertion with order-independent checks for the matched-row case, the unmatched Array default-fill path under join_use_nulls, and a mixed matched/unmatched aggregate result. The current revision also addresses the earlier inline review concerns, and I do not see any remaining correctness or PR-metadata issues in the current diff.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 11, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 11, 2026
…in_use_nulls_with_array_column`

Instead of `ORDER BY` between the join and the `LIMIT`, make the left input
deterministic by using a single-row `numbers(1)`, so the test still covers
`LIMIT` applied to a join result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits October 12, 2026 15:34
…ay_column`

The single-row left side `numbers(1)` only produced a matching row, so the
`ANY LEFT JOIN` no longer exercised the `join_use_nulls` path for unmatched
rows with an `Array` column on the right side. Ordering the left side before
the join is not reliable with parallel replicas, so make every query
order-independent instead, keeping `LIMIT` directly on the join result:
- `SEMI LEFT JOIN` over `numbers(10)` keeps only the matching row `0`;
- `ANY LEFT JOIN` over `numbers(1, 9)` has only unmatched rows, so any row
  gives the default `[]` for the `Array` column;
- `ANY LEFT JOIN` over `numbers(10)` with `LIMIT 10` mixes the matched and
  unmatched rows, and counting them is independent of the order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125133&sha=6cc8928c182dc47444011986661ce3d8c6dfd747&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 (05210_lightweight_update_materialized_cte_in_ignore, UNKNOWN_TABLE for _materialized_cte_* on a replica; also failing on master since 2026-10-09) and provide a fix in a separate PR. If the fix is already in progress, link it here. It looks like #112642, possibly fixed by #123121.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is already in progress: #123121 (mine, open).

This is the race from #112642: query 26 of 05210 sends id IN (subquery over a CTE referenced twice) to the replicas before the initiator has materialized _materialized_cte_c_*, so the replica cannot resolve the name. That is why all 140 reruns passed. On the current head of #123121 (eb9385ea, master merged today), 05210 passes in this same job. Nothing in this PR needs to change.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Thanks, @groeneai. The 05210 failure is tracked in #112642 and will be fixed by #123121, so this PR needs no change for it. CI on the current head (59cf6f3c) is green.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 13, 2026
Merged via the queue into master with commit 90caa6e Oct 13, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/flaky-00956-join-use-nulls-order branch October 13, 2026 15:06
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... 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

comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... 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