Skip to content

fix(pipeline): normalize retained dispatch receiver routes - #26025

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:agent/fix-issue25816-remote-dispatch-owner
Jul 23, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:agent/fix-issue25816-remote-dispatch-owner

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #25816

What this PR does / why we need it:

For a nested RemoteRun, encoding can retain a root Dispatch on the caller
CN while sending its child scope to the target CN. The decoded receiver metadata,
however, still carries the compile-time target CN in FromAddr. When runtime
placement selects a different caller CN, the retained Dispatch is registered
and executed on that caller, but the receiver sends its prepare notification to
the dormant compile-time target. The active Dispatch never receives its
stream and waits indefinitely.

This change normalizes FromAddr before remote-pipeline registration, limited
to receiver UUIDs owned by a root Dispatch that standalone RemoteRun
actually retains and executes on the current caller. Ordinary remotely executed
operator trees remain unchanged.

Since #25990, a non-standalone remote scope is rejected by
failRemoteRunBeforeStart; it no longer falls back to local MergeRun.
Normalization therefore stops at rejected scopes and does not rewrite routes
owned by their root, nested operators, or descendants. Regression tests pin
that rejection boundary.

The change does not alter planning, the wire format, dispatch semantics, RPC
timeouts, or cluster topology.

Validation on latest main (90e3400436):

  • focused regression, -count=20
  • focused regression with -race -count=3
  • full pkg/sql/compile package
  • full pkg/sql/compile package with -race
  • go build -mod=readonly ./pkg/sql/compile
  • go vet -mod=readonly ./pkg/sql/compile
  • git diff --check

The original issue reproduction was also validated on 10.222.1.50 before
this review follow-up: commit 51f629bd202b38b33fd5fc7d6b3052b0c8242db4
was built with make dev-build TYPECHECK=0, the 2-CN dev cluster was recreated,
and the reproduction query completed repeatedly through both CNs with identical
expected results, no lingering query, timeout, panic, receiver error, restart,
or OOM kill.

Regression coverage includes retained-root placement, ordinary remote-tree
negative control, rejected root and nested dispatches, rejected descendants,
unrelated UUIDs, and nil input.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@gouhongshen gouhongshen 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.

Codex automated review

No actionable regressions found. The normalization matches RemoteRun’s retained root-Dispatch ownership, runs before registration/goroutines, preserves ordinary remote dispatch routes, and adds focused positive/negative coverage. Existing PR discussion had no substantive reviews or inline threads. CI is green; local focused testing was unavailable because the required prebuilt libmo.dylib is absent.

@XuPeng-SH XuPeng-SH 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.

[P1] Normalize dispatch owners when RemoteRun falls back to local execution

The !checkPipelineStandaloneExecutableAtRemote(s) branch on lines 105-107 only descends into PreScopes, so it never records a Dispatch in this scope's own operator tree. This is inconsistent with RemoteRun: the same predicate makes it call s.MergeRun(c), which executes the entire scope (including its root/operator-tree Dispatch) on the caller CN. registerLocalDispatchReceivers likewise registers that whole fallback tree on the caller. Any matching receiver therefore keeps its compile-time FromAddr, sends prepare-notify to the dormant target CN, and never attaches to the active dispatch on the caller; the valid query retries/waits until its context is cancelled.

I reproduced this on the exact head with a Remote scope targeting cn2, a root dispatch, and a child connector whose external WaitRegister forces the standalone check to return false. After normalization on cn1, the receiver's owner was still cn2 (expected cn1). The existing TestGroupShuffleBucketsByCNIfNeeded documentation also identifies this reachable local-fallback/compile-time-FromAddr mismatch as a hang. Please collect dispatch UUIDs from every operator tree that the fallback MergeRun retains locally (and add root plus nested-dispatch regression cases), rather than scanning only the pre-scopes.

@LeftHandCold
LeftHandCold requested a review from XuPeng-SH July 22, 2026 14:28
@XuPeng-SH

Copy link
Copy Markdown
Contributor

@LeftHandCold need change

@gouhongshen gouhongshen 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.

Codex automated review

No actionable regressions found. The normalization matches RemoteRun’s retained root-Dispatch placement, stops at rejected scopes, runs before registration and goroutine startup, and preserves ordinary remote operator routes. Focused local tests could not start because libmo.dylib is absent; exact-head CI and reported focused/race suites passed.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr July 23, 2026 05:56
@XuPeng-SH
XuPeng-SH merged commit ebd05ba into matrixorigin:main Jul 23, 2026
24 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#26025)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25816

## What this PR does / why we need it:

For a nested `RemoteRun`, encoding can retain a root `Dispatch` on the
caller
CN while sending its child scope to the target CN. The decoded receiver
metadata,
however, still carries the compile-time target CN in `FromAddr`. When
runtime
placement selects a different caller CN, the retained `Dispatch` is
registered
and executed on that caller, but the receiver sends its prepare
notification to
the dormant compile-time target. The active `Dispatch` never receives
its
stream and waits indefinitely.

This change normalizes `FromAddr` before remote-pipeline registration,
limited
to receiver UUIDs owned by a root `Dispatch` that standalone `RemoteRun`
actually retains and executes on the current caller. Ordinary remotely
executed
operator trees remain unchanged.

Since matrixorigin#25990, a non-standalone remote scope is rejected by
`failRemoteRunBeforeStart`; it no longer falls back to local `MergeRun`.
Normalization therefore stops at rejected scopes and does not rewrite
routes
owned by their root, nested operators, or descendants. Regression tests
pin
that rejection boundary.

The change does not alter planning, the wire format, dispatch semantics,
RPC
timeouts, or cluster topology.

Validation on latest `main` (`90e3400436`):

- focused regression, `-count=20`
- focused regression with `-race -count=3`
- full `pkg/sql/compile` package
- full `pkg/sql/compile` package with `-race`
- `go build -mod=readonly ./pkg/sql/compile`
- `go vet -mod=readonly ./pkg/sql/compile`
- `git diff --check`

The original issue reproduction was also validated on `10.222.1.50`
before
this review follow-up: commit `51f629bd202b38b33fd5fc7d6b3052b0c8242db4`
was built with `make dev-build TYPECHECK=0`, the 2-CN dev cluster was
recreated,
and the reproduction query completed repeatedly through both CNs with
identical
expected results, no lingering query, timeout, panic, receiver error,
restart,
or OOM kill.

Regression coverage includes retained-root placement, ordinary
remote-tree
negative control, rejected root and nested dispatches, rejected
descendants,
unrelated UUIDs, and nil input.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#26025)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25816

## What this PR does / why we need it:

For a nested `RemoteRun`, encoding can retain a root `Dispatch` on the
caller
CN while sending its child scope to the target CN. The decoded receiver
metadata,
however, still carries the compile-time target CN in `FromAddr`. When
runtime
placement selects a different caller CN, the retained `Dispatch` is
registered
and executed on that caller, but the receiver sends its prepare
notification to
the dormant compile-time target. The active `Dispatch` never receives
its
stream and waits indefinitely.

This change normalizes `FromAddr` before remote-pipeline registration,
limited
to receiver UUIDs owned by a root `Dispatch` that standalone `RemoteRun`
actually retains and executes on the current caller. Ordinary remotely
executed
operator trees remain unchanged.

Since matrixorigin#25990, a non-standalone remote scope is rejected by
`failRemoteRunBeforeStart`; it no longer falls back to local `MergeRun`.
Normalization therefore stops at rejected scopes and does not rewrite
routes
owned by their root, nested operators, or descendants. Regression tests
pin
that rejection boundary.

The change does not alter planning, the wire format, dispatch semantics,
RPC
timeouts, or cluster topology.

Validation on latest `main` (`90e3400436`):

- focused regression, `-count=20`
- focused regression with `-race -count=3`
- full `pkg/sql/compile` package
- full `pkg/sql/compile` package with `-race`
- `go build -mod=readonly ./pkg/sql/compile`
- `go vet -mod=readonly ./pkg/sql/compile`
- `git diff --check`

The original issue reproduction was also validated on `10.222.1.50`
before
this review follow-up: commit `51f629bd202b38b33fd5fc7d6b3052b0c8242db4`
was built with `make dev-build TYPECHECK=0`, the 2-CN dev cluster was
recreated,
and the reproduction query completed repeatedly through both CNs with
identical
expected results, no lingering query, timeout, panic, receiver error,
restart,
or OOM kill.

Regression coverage includes retained-root placement, ordinary
remote-tree
negative control, rejected root and nested dispatches, rejected
descendants,
unrelated UUIDs, and nil input.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#26025)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25816

## What this PR does / why we need it:

For a nested `RemoteRun`, encoding can retain a root `Dispatch` on the
caller
CN while sending its child scope to the target CN. The decoded receiver
metadata,
however, still carries the compile-time target CN in `FromAddr`. When
runtime
placement selects a different caller CN, the retained `Dispatch` is
registered
and executed on that caller, but the receiver sends its prepare
notification to
the dormant compile-time target. The active `Dispatch` never receives
its
stream and waits indefinitely.

This change normalizes `FromAddr` before remote-pipeline registration,
limited
to receiver UUIDs owned by a root `Dispatch` that standalone `RemoteRun`
actually retains and executes on the current caller. Ordinary remotely
executed
operator trees remain unchanged.

Since matrixorigin#25990, a non-standalone remote scope is rejected by
`failRemoteRunBeforeStart`; it no longer falls back to local `MergeRun`.
Normalization therefore stops at rejected scopes and does not rewrite
routes
owned by their root, nested operators, or descendants. Regression tests
pin
that rejection boundary.

The change does not alter planning, the wire format, dispatch semantics,
RPC
timeouts, or cluster topology.

Validation on latest `main` (`90e3400436`):

- focused regression, `-count=20`
- focused regression with `-race -count=3`
- full `pkg/sql/compile` package
- full `pkg/sql/compile` package with `-race`
- `go build -mod=readonly ./pkg/sql/compile`
- `go vet -mod=readonly ./pkg/sql/compile`
- `git diff --check`

The original issue reproduction was also validated on `10.222.1.50`
before
this review follow-up: commit `51f629bd202b38b33fd5fc7d6b3052b0c8242db4`
was built with `make dev-build TYPECHECK=0`, the 2-CN dev cluster was
recreated,
and the reproduction query completed repeatedly through both CNs with
identical
expected results, no lingering query, timeout, panic, receiver error,
restart,
or OOM kill.

Regression coverage includes retained-root placement, ordinary
remote-tree
negative control, rejected root and nested dispatches, rejected
descendants,
unrelated UUIDs, and nil input.

---------

Co-authored-by: XuPeng-SH <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 30s remote dispatch watchdog can falsely fail slow receiver registration

5 participants