Repository navigation
fix(compile): preserve remote pipeline receiver ownership - #26603
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Distributed shuffle joins can leave a dispatch in one DOP bucket targeting local receivers owned by sibling buckets on the same CN. A following global merge then treats each bucket as an independent RemoteRun tree and rejects the dispatch-bearing tree. Detect this ownership violation at the common merge boundary and group the stage by CN before creating RemoteRun units. Keep independent pipelines unchanged and retain the runtime standalone guard. Add focused topology coverage and a multi-CN FULL OUTER JOIN plus WINDOW regression. Fixes #26595
0ac1117 to
8d9b02d
Compare
LeftHandCold
left a comment
There was a problem hiding this comment.
Deep-reviewed head 8d9b02d: no blocking issues found.
I traced the complete path from newMergeScope regrouping through per-CN scope construction, standalone validation, RemoteRun root stripping/serialization, local and remote dispatch registration, receiver notification, cancellation, and cleanup.
The regrouping is gated to non-local trees with an external in-process receiver dependency. Independent remote inputs and local dependencies retain the existing topology. Each original scope is attached exactly once, receiver/end counts remain consistent, wrapper growth is bounded by CN/input count, and error paths retain sibling cancellation plus bounded cleanup.
Focused race tests for the new Dispatch/Connector counterexamples, independent-input fast path, FULL OUTER JOIN -> WINDOW topology, and the existing standalone detector passed 3 consecutive runs with -p=1. The PR is based on current main, diff check is clean, and current GitHub checks have no failures or pending jobs.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No findings. The per-CN regrouping restores remote receiver ownership while preserving local and independent-input paths, cancellation, cleanup, boundedness, and compatibility. Tests cover Dispatch, Connector, fast-path, and FULL OUTER JOIN→WINDOW topologies. Diff and formatting checks are clean; focused local execution was unavailable because this worktree lacks MatrixOne’s native CGo prerequisites.
aptend
left a comment
There was a problem hiding this comment.
Reviewed the receiver-ownership regrouping and RemoteRun lifecycle paths. The focused topology tests, package tests, race tests, build, and vet pass locally.
…in#26603) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26595 ## What this PR does / why we need it: ### Root cause A distributed shuffle FULL OUTER JOIN creates multiple DOP receiver buckets per CN. A dispatch attached to one bucket can target local receivers owned by sibling buckets. When a following global operator such as WINDOW calls the common merge path, each bucket becomes a separate RemoteRun tree, so the dispatch-bearing tree is not standalone executable and is rejected before remote start. ### Fix - Extract the existing standalone receiver-ownership check into a pure compile-time detector while retaining the RemoteRun fail-fast guard. - At the common newMergeScope boundary, group an invalid remote input stage by CN so each serialized tree owns every in-process receiver it targets. - Preserve the direct path for local dependencies and independent remote inputs. - Add focused Dispatch and Connector counterexamples plus a distributed FULL OUTER JOIN to WINDOW topology regression. - Add an end-to-end multi-CN BVT using the existing optimizer shuffle data. ### Validation - Pre-fix focused counterexamples reproduced the defect: Dispatch and Connector inputs remained split, and FULL OUTER JOIN to WINDOW produced four non-standalone RemoteRun inputs instead of two per-CN trees. - Focused compile tests passed. - Full pkg/sql/compile passed under normal and race modes. - New topology tests each passed under race with count 100. - go list, go build, and go vet passed for pkg/sql/compile. - A latest-main binary at d29b475 passed the exact BVT SQL on a real two-CN cluster: MULTICN plan, FULL OUTER range shuffle, Window, and result both=2 / left_only=2 in 0.161s. ### Lifecycle audit - Q1 ownership: regrouped scopes, receivers, and connectors remain in the existing scope tree and retain single cleanup ownership. - Q2 unhappy paths: remote-start and merge failures keep the existing sibling cancellation and fail-before-start cleanup paths. - Q3 boundedness: detection is bounded by the input scope tree and added merge scopes are bounded by the CN count. ### Scope and risk No API, wire, catalog, or storage-format changes. Regrouping is compile-time only and triggers only when a remote input would otherwise be non-standalone. Independent stages retain their existing topology.
…in#26603) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26595 ## What this PR does / why we need it: ### Root cause A distributed shuffle FULL OUTER JOIN creates multiple DOP receiver buckets per CN. A dispatch attached to one bucket can target local receivers owned by sibling buckets. When a following global operator such as WINDOW calls the common merge path, each bucket becomes a separate RemoteRun tree, so the dispatch-bearing tree is not standalone executable and is rejected before remote start. ### Fix - Extract the existing standalone receiver-ownership check into a pure compile-time detector while retaining the RemoteRun fail-fast guard. - At the common newMergeScope boundary, group an invalid remote input stage by CN so each serialized tree owns every in-process receiver it targets. - Preserve the direct path for local dependencies and independent remote inputs. - Add focused Dispatch and Connector counterexamples plus a distributed FULL OUTER JOIN to WINDOW topology regression. - Add an end-to-end multi-CN BVT using the existing optimizer shuffle data. ### Validation - Pre-fix focused counterexamples reproduced the defect: Dispatch and Connector inputs remained split, and FULL OUTER JOIN to WINDOW produced four non-standalone RemoteRun inputs instead of two per-CN trees. - Focused compile tests passed. - Full pkg/sql/compile passed under normal and race modes. - New topology tests each passed under race with count 100. - go list, go build, and go vet passed for pkg/sql/compile. - A latest-main binary at d29b475 passed the exact BVT SQL on a real two-CN cluster: MULTICN plan, FULL OUTER range shuffle, Window, and result both=2 / left_only=2 in 0.161s. ### Lifecycle audit - Q1 ownership: regrouped scopes, receivers, and connectors remain in the existing scope tree and retain single cleanup ownership. - Q2 unhappy paths: remote-start and merge failures keep the existing sibling cancellation and fail-before-start cleanup paths. - Q3 boundedness: detection is bounded by the input scope tree and added merge scopes are bounded by the CN count. ### Scope and risk No API, wire, catalog, or storage-format changes. Regrouping is compile-time only and triggers only when a remote input would otherwise be non-standalone. Independent stages retain their existing topology.
…in#26603) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26595 ## What this PR does / why we need it: ### Root cause A distributed shuffle FULL OUTER JOIN creates multiple DOP receiver buckets per CN. A dispatch attached to one bucket can target local receivers owned by sibling buckets. When a following global operator such as WINDOW calls the common merge path, each bucket becomes a separate RemoteRun tree, so the dispatch-bearing tree is not standalone executable and is rejected before remote start. ### Fix - Extract the existing standalone receiver-ownership check into a pure compile-time detector while retaining the RemoteRun fail-fast guard. - At the common newMergeScope boundary, group an invalid remote input stage by CN so each serialized tree owns every in-process receiver it targets. - Preserve the direct path for local dependencies and independent remote inputs. - Add focused Dispatch and Connector counterexamples plus a distributed FULL OUTER JOIN to WINDOW topology regression. - Add an end-to-end multi-CN BVT using the existing optimizer shuffle data. ### Validation - Pre-fix focused counterexamples reproduced the defect: Dispatch and Connector inputs remained split, and FULL OUTER JOIN to WINDOW produced four non-standalone RemoteRun inputs instead of two per-CN trees. - Focused compile tests passed. - Full pkg/sql/compile passed under normal and race modes. - New topology tests each passed under race with count 100. - go list, go build, and go vet passed for pkg/sql/compile. - A latest-main binary at d29b475 passed the exact BVT SQL on a real two-CN cluster: MULTICN plan, FULL OUTER range shuffle, Window, and result both=2 / left_only=2 in 0.161s. ### Lifecycle audit - Q1 ownership: regrouped scopes, receivers, and connectors remain in the existing scope tree and retain single cleanup ownership. - Q2 unhappy paths: remote-start and merge failures keep the existing sibling cancellation and fail-before-start cleanup paths. - Q3 boundedness: detection is bounded by the input scope tree and added merge scopes are bounded by the CN count. ### Scope and risk No API, wire, catalog, or storage-format changes. Regrouping is compile-time only and triggers only when a remote input would otherwise be non-standalone. Independent stages retain their existing topology.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin/matrixflow#21396. ## What this PR does / why we need it: ### Root cause and branch-specific fix A distributed shuffle aggregate creates multiple receiver buckets per CN. A Dispatch attached to one bucket can target local receivers owned by sibling buckets. A following global Window uses `newMergeScope`, which previously split those buckets into independent RemoteRun trees. The old runtime then moved a non-standalone tree onto the coordinator without changing the compile-time notification addresses, causing remote Dispatch registration timeouts. Adapt the common ownership fix from #26603 to `4.1.6-hotfix`: - Extract a pure receiver-ownership detector and reuse it during compilation and the existing runtime check. Preserve the root output retained on the caller. - Before constructing a common merge's receivers, group dependent inputs by their actual CN. Preserve every input, including nodes outside `cnList`, along with operator chains, receiver identities, UUIDs and `FromAddr`. - Keep independent remote inputs and local-only dependencies on the existing path. - Add Dispatch/Connector ownership controls and actual Range/Hash Shuffle GROUP → Window topology tests. - Extend the existing shuffle BVT fixture with ranked top-five rows, COUNT wrapping and a UNION ALL total; add no new large-data setup. This is a focused adaptation, not a wholesale cherry-pick of the newer scheduler. It does not change the existing RemoteRun fallback/error protocol, registration timeout, or wire/catalog/storage formats. ### Validation Validated on darwin/arm64 with Go 1.26.4 and branch-matched native libraries. The delivered source hashes at `a30a0368f0` match the validated sources. - New counterexamples fail before the fix for missing ownership grouping; the same assertions and directly affected existing tests pass afterward. - Five focused topology/lifecycle tests each pass 100 repetitions under `-race`, including merge cancellation, blocked remote forwarding cancellation and empty Dispatch completion. - Service build, matching gofmt, `go vet`, and incremental repository-pinned golangci-lint 2.6.2 pass. - New grouping function coverage: 100%; extracted detector: 89.7%; other directly modified functions: 100%. - Full `optimizer/shuffle.test` passes twice on an isolated two-CN cluster: **75 successful, 0 failed, 9 pre-existing ignored cases** each, in 20.473s / 19.250s. All three new cases execute. The original case on the same binary takes 15.746s. - Each CN separately executes all three new SQL shapes with independently checked results. Plans show MULTICN + range shuffle + Window; the physical execution plan contains both CN addresses. - Test databases are removed and the owned cluster exits with code 0. No production SQL replay or deployment was performed. ### Known baseline failures Full `pkg/sql/compile` is **not green** in this local environment. Both normal and race runs fail the following tests; clean `54feca6423` worktree runs with the same modes reproduce the identical assertion failures: - `TestCompileExternScanParquetLoadUsesRowGroupFanoutWithEmptyFiles`: expected two scopes, got one. - `TestCompileExternScanParquetRowGroupFanoutValidatesEmptyFileColumnCount`: expected an error, got nil. - `TestCompileExternScanParquetLoadUsesFileFanoutMainPath`: expected two scopes, got one. These failures are not introduced by this change; the tests were neither skipped nor weakened. No race detector finding was reported. Local commands, terminal logs, source hashes and the detailed report are retained under the task worktree's `CLAUDE_VALIDATION/` and are intentionally not committed. ### CI follow-up (2026-11-12) Merged current upstream `4.1.6-hotfix` (`bf18d10904`, #32519) without conflicts; updated head: `089cb315ae2de0d85ff55b3188b37eee036ded63`. The PR remains the original five-file receiver-ownership change; no unrelated fixture, assertion, timeout or CI-harness changes are included. The preceding Ubuntu race attempt was not green. Its failures are tracked separately: - DML's shared branch-diff deadline: existing #32544. - `TestPreparedParams` / `TestCalculateObjectCount` bootstrap failures in the serialized embedded stage: #32614. - S3 merge-count assertion recurrence: #32615 (historical closed #25550). - Attempt 1's `TestReplay1` fixed-port collision matches historical #26165 and did not recur in attempt 2. On the merged head, an explicitly selected local run with Go 1.26.4, matching native libraries, `-race -short -tags matrixone_test -count=1 -p 1` passes all selected original failed tests, the preceding `Test_TxnExecutorExec`, remote-ownership regressions, and `TestWindowResultNullability` across six packages (exit 0). This is Darwin/arm64 evidence, not a reproduction or repair guarantee for the Linux runner failures. No root-cause equivalence with historical issues or full CI success is claimed. The push starts a new CI generation; its outcome remains pending.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26595
What this PR does / why we need it:
Root cause
A distributed shuffle FULL OUTER JOIN creates multiple DOP receiver buckets per CN. A dispatch attached to one bucket can target local receivers owned by sibling buckets. When a following global operator such as WINDOW calls the common merge path, each bucket becomes a separate RemoteRun tree, so the dispatch-bearing tree is not standalone executable and is rejected before remote start.
Fix
Validation
Lifecycle audit
Scope and risk
No API, wire, catalog, or storage-format changes. Regrouping is compile-time only and triggers only when a remote input would otherwise be non-standalone. Independent stages retain their existing topology.