Skip to content

Fix incorrect results for RIGHT ANY JOIN - #102064

Merged
fm4v merged 6 commits into
masterfrom
vdimir/right_any_join_bug_issue_99431
May 19, 2026
Merged

fm4v merged 6 commits into
masterfrom
vdimir/right_any_join_bug_issue_99431

Conversation

@vdimir

@vdimir vdimir commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Linked issues

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Version info

  • Merged into: 26.5.1.857
  • Backported to: 26.4.3.39, 26.3.11.33, 26.2.19.41

@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0ca2830]

Summary: ✅


AI Review

Summary

This PR fixes incorrect RIGHT ANY JOIN output slicing in HashJoinResult::next when joined blocks are split, by slicing RHS columns using cumulative RHS offset (prev_offset) instead of LHS row index (start_row). The added stateless regression test covers both a minimal split case and a multi-JOIN query shape tied to the reported issue. I did not find remaining correctness, safety, or performance concerns in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Apr 8, 2026
@vdimir vdimir changed the title fixing right any join Fix incorrect results for RIGHT ANY JOIN Apr 8, 2026
@vdimir
vdimir marked this pull request as ready for review April 8, 2026 14:47
@alexey-milovidov

Copy link
Copy Markdown
Member

The 02346_text_index_bug101913 test failure is fixed by #102108 (already merged). Please rebase or merge master to pick up the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member

The Fast test (arm_darwin) failure is unrelated to this PR — the fix is in #102184.

@Shlomixg

Copy link
Copy Markdown

Would appreciate getting this merged and backported to 26.3, It's an important fix for our use case

@m-selmi m-selmi self-assigned this Apr 16, 2026

@m-selmi m-selmi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Shlomixg

Copy link
Copy Markdown

Can it be merged?

@Shlomixg

Shlomixg commented May 5, 2026

Copy link
Copy Markdown

Is there any reason this PR hasn't been merged yet?
I'd like to know the timeline, as this issue is blocking us from upgrading and developing a workaround would take considerable time.

@vdimir

vdimir commented May 12, 2026

Copy link
Copy Markdown
Member Author

@Shlomixg sorry for delaying the fix, there were issues with CI, hope we can land it soon

@fm4v

fm4v commented May 19, 2026

Copy link
Copy Markdown
Member

@groeneai please update the PR and continue the fix

@groeneai

Copy link
Copy Markdown
Collaborator

@fm4v @vdimir cc @alexey-milovidov @azat

Thanks for the ping. I can't push to this branch — it lives on the upstream ClickHouse repo (vdimir is a maintainer with direct write access here) and our policy is no commits to others' branches. But I can share CI analysis, because this PR is closer to mergeable than the red Mergeable Check suggests.

Of the 170+ checks on commit 1b0ef7d, every real test/build is green. Only 4 statuses are non-success, and all are infrastructure noise:

Check Cause
Code Review Copilot subprocess crashed and retried 3× without producing a review — RuntimeError: Copilot review failed after 3 attempts: copilot subprocess exited with non-OK status (job.log). Not a verdict on the code.
CH Inc sync ClickHouse Inc internal sync — only the team can clear.
Mergeable Check Umbrella — red because of the two above.
Fast test (arm_darwin) (6 tests) All 6 are server died / [Errno 61] Connection refused from the macOS runner — unrelated to RIGHT ANY JOIN. CIDB confirms this is chronic infra: 4 547 failing test cases across 805 unrelated PRs in 30 days, "Server died" being the dominant cause (1 933 hits / 585 PRs). @alexey-milovidov already confirmed arm_darwin on this PR was unrelated back in April (#102184).

The diff is tiny and targeted: 1 line in HashJoinResult.cpp + a 43-line regression test (04075_right_any_join_incorrect.sql). @m-selmi's April 16 LGTM still stands — no code changes since (last edit was the May 12 merge from master).

What would unblock the merge:

  • Retrigger the Code Review job (Copilot transient infra failure).
  • Clear or override CH Inc sync from the internal side.
  • Mergeable Check will then go green, ready to merge + backport per the pr-must-backport label.

@vdimir is otherwise active (merged #104017 and #104998 earlier today UTC, opened #105296 shortly after this ping), so a direct nudge should reach him if you'd prefer he push the merge button. @Shlomixg's upgrade has been blocked >1 month on CI infra noise rather than on code — would be good to land this.

@clickhouse-gh

clickhouse-gh Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.10% +0.10%
Functions 91.40% 91.40% +0.00%
Branches 76.50% 76.60% +0.10%

Changed lines: 100.00% (5/5) · Uncovered code

Full report · Diff report

@fm4v
fm4v added this pull request to the merge queue May 19, 2026
Merged via the queue into master with commit 2650e5f May 19, 2026
165 checks passed
@fm4v
fm4v deleted the vdimir/right_any_join_bug_issue_99431 branch May 19, 2026 19:17
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 19, 2026
robot-ch-test-poll4 added a commit that referenced this pull request May 19, 2026
Cherry pick #102064 to 26.4: Fix incorrect results for RIGHT ANY JOIN
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 19, 2026
vdimir added a commit that referenced this pull request May 20, 2026
Backport #102064 to 26.2: Fix incorrect results for RIGHT ANY JOIN
vdimir added a commit that referenced this pull request May 20, 2026
Backport #102064 to 26.3: Fix incorrect results for RIGHT ANY JOIN
vdimir added a commit that referenced this pull request May 20, 2026
Backport #102064 to 26.4: Fix incorrect results for RIGHT ANY JOIN
@watson-ch watson-ch Bot added v25.10-must-backport v25.12-must-backport and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels May 22, 2026
@watson-ch

watson-ch Bot commented May 22, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/ClickHouse/clickhouse-core-incidents/issues/497

Labels added:

  • v25.8-must-backport
  • v25.10-must-backport
  • v25.12-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 22, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 22, 2026
@watson-ch watson-ch Bot added v26.2-must-backport and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Jun 17, 2026
@watson-ch

watson-ch Bot commented Jun 17, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/497

Labels added:

  • v26.2-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 17, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jun 17, 2026
@watson-ch watson-ch Bot added v26.7-must-backport and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Aug 17, 2026
@watson-ch

watson-ch Bot commented Aug 17, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/497

Labels added:

  • v26.7-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Aug 17, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…2064

Backport ClickHouse#102064 to 26.4: Fix incorrect results for RIGHT ANY JOIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport v26.2-must-backport v26.7-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LEFT ANY JOIN produces incorrect duplicate rows when query_plan_use_logical_join_step = 1 (default)