Skip to content

Fix full merge join gang size crash in ORCA - #1896

Open
roseduan wants to merge 3 commits into
apache:mainfrom
roseduan:roseduan_fix_orca_unexpected_gang_size
Open

Fix full merge join gang size crash in ORCA#1896
roseduan wants to merge 3 commits into
apache:mainfrom
roseduan:roseduan_fix_orca_unexpected_gang_size

Conversation

@roseduan

Copy link
Copy Markdown
Contributor

CPhysicalFullMergeJoin::PdsDerive unconditionally returned the outer child's distribution spec whenever it was Universal, ignoring the inner child's real distribution. When the inner child was actually Singleton (gathered to combine with a Universal/empty outer side), the join's output was mislabeled Universal.

Universal trivially satisfies a Replicated requirement, so an enclosing per-segment join (e.g. a comma-join with a third relation) skipped the corrective motion this Singleton child needed, nesting a real cross-segment Gather Motion inside a per-segment execution context. The executor's sanity check in ExecInitMotion (nodeMotion.c) caught the inconsistent slice and raised "unexpected gang size: N".

Fix by mirroring the already-correct sibling implementations (CPhysicalFullHashJoin::PdsDerive, CPhysicalHashJoin:: PdsDeriveForOuterJoin): propagate the inner child's real distribution instead of blindly returning the outer's.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


roseduan and others added 3 commits August 17, 2026 18:34
CPhysicalFullMergeJoin::PdsDerive unconditionally returned the
outer child's distribution spec whenever it was Universal,
ignoring the inner child's real distribution. When the inner
child was actually Singleton (gathered to combine with a
Universal/empty outer side), the join's output was mislabeled
Universal.

Universal trivially satisfies a Replicated requirement, so an
enclosing per-segment join (e.g. a comma-join with a third
relation) skipped the corrective motion this Singleton child
needed, nesting a real cross-segment Gather Motion inside a
per-segment execution context. The executor's sanity check in
ExecInitMotion (nodeMotion.c) caught the inconsistent slice and
raised "unexpected gang size: N".

Fix by mirroring the already-correct sibling implementations
(CPhysicalFullHashJoin::PdsDerive, CPhysicalHashJoin::
PdsDeriveForOuterJoin): propagate the inner child's real
distribution instead of blindly returning the outer's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant