Repository navigation
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Requesting changes on head 6a5784ebc.
The two primary fixes are directionally correct: a typed retry attempt no longer tombstones an absent query-wide receiver, and local/coordinator receiver registration now happens before scope goroutines start. The scope ownership traversal, retained-root state transfer, cancellation on RemoteRun failure, and owner-token cleanup all look coherent under the covered paths.
High: a failed duplicate registration still deletes the existing live/attached owner
Server.PutProcIntoUuidMap still mutates the registry destructively on conflict (pkg/sql/colexec/server.go:105-110): whenever the UUID already exists, it deletes that entry and then returns remote receiver ... already done.
That violates the atomicity promised by the new owner-checked rollback. prepareRemote can successfully register UUID A and then encounter an existing owner for UUID B. It rolls back A using the new channel owner token, but B has already been deleted by PutProcIntoUuidMap even though B was never owned by this registration attempt. The previous valid receiver can no longer attach, and subsequent notification falls back to NotRegistered/timeout behavior, recreating the exact registry artifact this PR is intended to remove.
I reproduced this deterministically with a temporary regression:
- pre-register UUID B with
oldProc/oldCh; - register a new Dispatch containing
[A, B]; - registration of A succeeds and B conflicts;
- the call returns an error, then
GetProcByUuid(B, false)returnsok=falseinstead of the original owner.
The assertion fails on the current head with:
Should be true: a failed duplicate registration deleted the existing owner
The current tests miss this because TestPutProcIntoUuidMapConflictIncludesUuidAndState checks only the error text, and TestRegisterRemoteReceiversRollbackOnPartialFailure checks only that this attempt removes A; neither verifies that the pre-existing B owner survives.
Please make conflict handling non-destructive for an existing live or attached registration. Note that proc == nil alone is not enough to classify an entry as a cancellation tombstone: an attached registration also has proc/ch == nil but retains a non-nil ownerCh. At minimum the state handling should distinguish:
- live owner:
proc != nil, preserve it; - attached owner:
proc == nil && ownerCh != nil, preserve it; - pre-registration cancellation tombstone: no owner token, apply the explicitly intended tombstone transition.
Then add regressions for both live-owner and attached-owner conflicts, including the [A, conflicting B] partial-registration rollback. Only UUIDs written by the failing attempt should be removed.
Local validation on the PR head:
go test ./pkg/sql/colexec ./pkg/sql/colexec/dispatch -count=1
PASS
go test -race ./pkg/sql/compile -run focused-registration-tests -count=5
PASS
temporary existing-owner preservation regression
FAIL deterministically
CI currently has no failed checks, but this uncovered ownership case is a correctness blocker independent of CI.
|
Addressed the change request in
Validation:
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Approved on head b17ff9b33d897568134e111e919a375e0783ba01.
The previous correctness blocker is resolved. Registration conflicts are now non-destructive for both live and attached owners, while only an ownerless cancellation tombstone is consumed. The new direct registry tests and [A, conflicting B] partial-registration regressions verify that rollback removes only entries owned by the failing attempt.
I also rechecked the broader lifecycle:
- local/coordinator receivers are published before any scope goroutine starts;
- remote-owned subtrees are skipped while retained remote roots are registered with the owning scope process;
- repeated traversal is idempotent and retained-root cleanup state is transferred back safely;
- partial registration failure cancels affected processes and performs owner-checked rollback;
- RemoteRun failure cancels the owner process, releasing a notify blocked before Dispatch.Prepare;
- normal/error cleanup removes live or attached entries without allowing delayed cleanup to delete a newer owner.
No production hot-path regression was found. The extra work is one pre-execution scope/operator walk plus the same O(receiver) registry inserts that previously occurred during Prepare. The explicit registry state-machine redesign remains useful follow-up hardening, but I did not find it necessary to close either proven race fixed here.
Local validation:
go test ./pkg/sql/colexec ./pkg/sql/colexec/dispatch -count=1- focused compile registration/interleaving tests under
-race -count=10 - owner/conflict/rollback tests under
-race -count=20 git diff --check
All CI checks, including UT, multi-CN BVT, coverage, benchmark, and both upgrade jobs, are green.
## 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#25565 Related to matrixorigin#25211 ## What this PR does / why we need it: This PR fixes two remote dispatch registration races found while investigating the recurring Hive JOIN failures in matrixorigin#25211: 1. A retry attempt no longer tombstones an absent receiver UUID when its RPC connection closes. The attempt connection does not own the query-wide receiver lifecycle, so late registration remains attachable by the next retry. 2. Coordinator/local dispatch receivers are published before `Compile.runOnce` starts any scope goroutine. This establishes the required happens-before relation between receiver registration and remote notification. The implementation also: - registers each dispatch with its owning `scope.Proc`; - distinguishes local scope trees, coordinator-retained remote root dispatches, and remote-owned subtrees; - transfers early-registration state to the retained local dispatch runner to avoid duplicate registration; - cancels owner processes and performs owner-checked rollback on partial registration failure; - releases pending attaches when `RemoteRun` fails before `Dispatch.Prepare`; - includes receiver UUID and the previous `live`/`tombstone` state in registration conflict errors. A full registry state-machine redesign remains possible follow-up hardening, but is not required for these two proven failure paths. ## Validation - `go test -count=1 ./pkg/sql/colexec ./pkg/sql/colexec/dispatch` - focused `go test -race` across `pkg/sql/colexec`, `pkg/sql/colexec/dispatch`, and `pkg/sql/compile` - `go build ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compile` - `go vet ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compile` - `git diff --check` The full `pkg/sql/compile` suite still has three parquet external-scan fanout failures; the same command and assertions fail on clean base commit `0fcd615a7f`, so they are unrelated to this change. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
## 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#25565 Related to matrixorigin#25211 ## What this PR does / why we need it: This PR fixes two remote dispatch registration races found while investigating the recurring Hive JOIN failures in matrixorigin#25211: 1. A retry attempt no longer tombstones an absent receiver UUID when its RPC connection closes. The attempt connection does not own the query-wide receiver lifecycle, so late registration remains attachable by the next retry. 2. Coordinator/local dispatch receivers are published before `Compile.runOnce` starts any scope goroutine. This establishes the required happens-before relation between receiver registration and remote notification. The implementation also: - registers each dispatch with its owning `scope.Proc`; - distinguishes local scope trees, coordinator-retained remote root dispatches, and remote-owned subtrees; - transfers early-registration state to the retained local dispatch runner to avoid duplicate registration; - cancels owner processes and performs owner-checked rollback on partial registration failure; - releases pending attaches when `RemoteRun` fails before `Dispatch.Prepare`; - includes receiver UUID and the previous `live`/`tombstone` state in registration conflict errors. A full registry state-machine redesign remains possible follow-up hardening, but is not required for these two proven failure paths. ## Validation - `go test -count=1 ./pkg/sql/colexec ./pkg/sql/colexec/dispatch` - focused `go test -race` across `pkg/sql/colexec`, `pkg/sql/colexec/dispatch`, and `pkg/sql/compile` - `go build ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compile` - `go vet ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compile` - `git diff --check` The full `pkg/sql/compile` suite still has three parquet external-scan fanout failures; the same command and assertions fail on clean base commit `0fcd615a7f`, so they are unrelated to this change. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
## 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#25565 Related to matrixorigin#25211 ## What this PR does / why we need it: This PR fixes two remote dispatch registration races found while investigating the recurring Hive JOIN failures in matrixorigin#25211: 1. A retry attempt no longer tombstones an absent receiver UUID when its RPC connection closes. The attempt connection does not own the query-wide receiver lifecycle, so late registration remains attachable by the next retry. 2. Coordinator/local dispatch receivers are published before `Compile.runOnce` starts any scope goroutine. This establishes the required happens-before relation between receiver registration and remote notification. The implementation also: - registers each dispatch with its owning `scope.Proc`; - distinguishes local scope trees, coordinator-retained remote root dispatches, and remote-owned subtrees; - transfers early-registration state to the retained local dispatch runner to avoid duplicate registration; - cancels owner processes and performs owner-checked rollback on partial registration failure; - releases pending attaches when `RemoteRun` fails before `Dispatch.Prepare`; - includes receiver UUID and the previous `live`/`tombstone` state in registration conflict errors. A full registry state-machine redesign remains possible follow-up hardening, but is not required for these two proven failure paths. ## Validation - `go test -count=1 ./pkg/sql/colexec ./pkg/sql/colexec/dispatch` - focused `go test -race` across `pkg/sql/colexec`, `pkg/sql/colexec/dispatch`, and `pkg/sql/compile` - `go build ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compile` - `go vet ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compile` - `git diff --check` The full `pkg/sql/compile` suite still has three parquet external-scan fanout failures; the same command and assertions fail on clean base commit `0fcd615a7f`, so they are unrelated to this change. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #25565
Related to #25211
What this PR does / why we need it:
This PR fixes two remote dispatch registration races found while investigating the recurring Hive JOIN failures in #25211:
Compile.runOncestarts any scope goroutine. This establishes the required happens-before relation between receiver registration and remote notification.The implementation also:
scope.Proc;RemoteRunfails beforeDispatch.Prepare;live/tombstonestate in registration conflict errors.A full registry state-machine redesign remains possible follow-up hardening, but is not required for these two proven failure paths.
Validation
go test -count=1 ./pkg/sql/colexec ./pkg/sql/colexec/dispatchgo test -raceacrosspkg/sql/colexec,pkg/sql/colexec/dispatch, andpkg/sql/compilego build ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compilego vet ./pkg/sql/colexec ./pkg/sql/colexec/dispatch ./pkg/sql/compilegit diff --checkThe full
pkg/sql/compilesuite still has three parquet external-scan fanout failures; the same command and assertions fail on clean base commit0fcd615a7f, so they are unrelated to this change.