Skip to content

fix: register local dispatches below remote scopes - #25664

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/25211-remote-dispatch-return-registration
Jul 13, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/25211-remote-dispatch-return-registration

Conversation

@aptend

@aptend aptend commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #25211

Fixes #25211

What this PR does / why we need it:

The early dispatch-receiver registration pass stops at a Remote scope when that tree can execute independently on another CN and its root is not a Dispatch. Such a remote tree can still contain a child Remote scope that returns execution to the coordinator CN. Its local dispatch receiver is therefore never published, and the remote sender retries TryGetProcByUuid until the 30-second timeout.

Keep the outer remote operator tree remote-only, but continue walking its PreScopes. This publishes only dispatch receivers that will execute locally after a nested return RemoteRun. Retained remote Dispatch roots also continue to their child scopes.

Regression coverage exercises both a remote non-Dispatch root and a retained remote Dispatch root with a nested local-return scope.

Tests:

  • go test -race ./pkg/sql/compile -run "^TestRegisterLocalDispatchReceiversTraversesRemoteAncestorForNestedLocalReturn$" -count=1
  • go test ./pkg/sql/compile -count=1

@aptend
aptend requested review from XuPeng-SH and aunjgr as code owners July 13, 2026 08:52
@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 →

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

LGTM after reviewing this from the execution-topology, registration-lifecycle, and unhappy-path angles.

  • correctness: the local registration pass now keeps walking PreScopes below a standalone remote non-Dispatch ancestor, which is the missing path behind the 30s TryGetProcByUuid timeout
  • containment: the change still avoids registering the remote-only operator tree itself, and retained remote Dispatch roots keep the old root-only behavior while also reaching nested local-return children
  • unhappy path coverage: the new regression covers both the remote non-Dispatch root and the retained remote Dispatch root cases, which are the two important nested-return shapes here

I did not find a remaining correctness or hang issue in the latest diff, so approving.

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## 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:

issue matrixorigin#25211

Fixes matrixorigin#25211

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

The early dispatch-receiver registration pass stops at a Remote scope
when that tree can execute independently on another CN and its root is
not a Dispatch. Such a remote tree can still contain a child Remote
scope that returns execution to the coordinator CN. Its local dispatch
receiver is therefore never published, and the remote sender retries
`TryGetProcByUuid` until the 30-second timeout.

Keep the outer remote operator tree remote-only, but continue walking
its `PreScopes`. This publishes only dispatch receivers that will
execute locally after a nested return RemoteRun. Retained remote
Dispatch roots also continue to their child scopes.

Regression coverage exercises both a remote non-Dispatch root and a
retained remote Dispatch root with a nested local-return scope.

## Tests:

- `go test -race ./pkg/sql/compile -run
"^TestRegisterLocalDispatchReceiversTraversesRemoteAncestorForNestedLocalReturn$"
-count=1`
- `go test ./pkg/sql/compile -count=1`

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## 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:

issue matrixorigin#25211

Fixes matrixorigin#25211

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

The early dispatch-receiver registration pass stops at a Remote scope
when that tree can execute independently on another CN and its root is
not a Dispatch. Such a remote tree can still contain a child Remote
scope that returns execution to the coordinator CN. Its local dispatch
receiver is therefore never published, and the remote sender retries
`TryGetProcByUuid` until the 30-second timeout.

Keep the outer remote operator tree remote-only, but continue walking
its `PreScopes`. This publishes only dispatch receivers that will
execute locally after a nested return RemoteRun. Retained remote
Dispatch roots also continue to their child scopes.

Regression coverage exercises both a remote non-Dispatch root and a
retained remote Dispatch root with a nested local-return scope.

## Tests:

- `go test -race ./pkg/sql/compile -run
"^TestRegisterLocalDispatchReceiversTraversesRemoteAncestorForNestedLocalReturn$"
-count=1`
- `go test ./pkg/sql/compile -count=1`

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## 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:

issue matrixorigin#25211

Fixes matrixorigin#25211

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

The early dispatch-receiver registration pass stops at a Remote scope
when that tree can execute independently on another CN and its root is
not a Dispatch. Such a remote tree can still contain a child Remote
scope that returns execution to the coordinator CN. Its local dispatch
receiver is therefore never published, and the remote sender retries
`TryGetProcByUuid` until the 30-second timeout.

Keep the outer remote operator tree remote-only, but continue walking
its `PreScopes`. This publishes only dispatch receivers that will
execute locally after a nested return RemoteRun. Retained remote
Dispatch roots also continue to their child scopes.

Regression coverage exercises both a remote non-Dispatch root and a
retained remote Dispatch root with a nested local-return scope.

## Tests:

- `go test -race ./pkg/sql/compile -run
"^TestRegisterLocalDispatchReceiversTraversesRemoteAncestorForNestedLocalReturn$"
-count=1`
- `go test ./pkg/sql/compile -count=1`

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 kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hive partition JOIN queries intermittently fail with dispatch timeout (dispatch process not registered within 30s)

3 participants