Repository navigation
fix(dispatch): preserve terminal results for late remote receivers - #28326
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.
Reviewed exact head 14595165fa1041371992ce35e0337b9d6a3fabb0. No confirmed blocking issue found.
The fix addresses the correct invariant: cancellation of a local pipeline context during normal cleanup is not the source's execution result. A registration-generation-owned terminal publishes the actual Reset result once; its done-channel close establishes visibility of the immutable error before readers inspect it. Publication precedes cleanup operations that can wait for consumers, avoiding a terminal-result/cleanup wait cycle.
I checked attached and late-notify paths, first-result/duplicate behavior, partial registration rollback, request cancellation and connection loss, owner-specific registry cleanup, waiter retention/release, and operator/process reuse. Capturing the original cancel function and terminal avoids dereferencing a reused Process for terminal waiting or cancellation. Ready-to-finished retains a result for the late consumer, whereas final registration cleanup and the last published waiter release provide the reclamation boundary. Delayed cleanup is guarded by the owner channel and cannot remove a replacement generation. Existing wire End/Error encoding is unchanged, and external request cancellation is explicitly rechecked after terminal readiness.
The deterministic tests cover before/after attachment, finished registration with an existing waiter, source failure, cancellation/deadline, rollback without Reset, immutable first outcome, and replacement-generation safety. The SQL regression keeps the recursive query shape, checks nonempty → empty → restored results, and verifies actual remote attachment rather than treating a local-only execution as proof. The latest increment correctly scopes result-set Close with defer.
Cost is per registration (terminal object/channel and existing registry synchronization), not per transmitted row or batch. No new polling loop or background worker is introduced. I did not identify a concrete new memory-retention, deadlock or error-loss blocker in the inspected lifecycle.
Evidence in this round: full diff and relevant registration/Reset/notify/waiter/caller source review, test inspection, and git diff --check. The PR reports clean-main falsification plus normal/race suites and repeated lifecycle tests; these are reported author evidence, not fresh executions by this reviewer. I did not rebuild/run a native cluster or race suite and did not wait for CI.
Merge Queue Status
This pull request spent 25 minutes 42 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28326 has been merged manually at 4503c3b Failing checks:
HintYou were too fast! Tick the box to put this pull request back in the merge queue (same as
|
…atrixorigin#28326) ## 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#28313 ## What this PR does / why we need it: An empty recursive join build can finish a preregistered dispatch before its remote receiver attaches. Normal pipeline cleanup cancels the local context, and a late notify incorrectly turns that cancellation into `Error 20101: internal error: convert go error to mo error context canceled` instead of returning an empty result. Publish an immutable terminal result for each dispatch registration before cleanup can wait. Attached and late receivers consume that result, while registration rollback preserves its failure cause. Capture the registration's original cancellation context so late notifications cannot cancel a reused process. Genuine execution errors, request cancellation, and connection failures remain errors; the existing End/Error wire format is unchanged. Add deterministic tests for completion before/after attachment, waiter cleanup, rollback, cancellation, and process reuse. The SQL regression uses the original recursive query with small synthetic tables and patched statistics, and checks that remote receiver attachment actually occurs. Validation on commit `9bc213ea37`: - Same SQL regression on clean main `3d67664696`: fails on the first empty-result query with the matching 20101 error. - Fixed SQL regression: passes all nine queries across the 500-row, zero-row, and restored 500-row phases on the shared multi-CN cluster (14.2 seconds including startup). - Full `pkg/sql/colexec`, `pkg/sql/colexec/dispatch`, and `pkg/sql/compile` test suites pass normally and under `-race` using the repository CGo wrapper. - Eight focused lifecycle/concurrency tests each pass 100 repetitions under `-race`. - CI follow-up `14595165fa`: close each SQL result set with a scoped defer; the SQL regression and focused `sqlclosecheck`/`rowserrcheck` validation pass locally. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…atrixorigin#28326) ## 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#28313 ## What this PR does / why we need it: An empty recursive join build can finish a preregistered dispatch before its remote receiver attaches. Normal pipeline cleanup cancels the local context, and a late notify incorrectly turns that cancellation into `Error 20101: internal error: convert go error to mo error context canceled` instead of returning an empty result. Publish an immutable terminal result for each dispatch registration before cleanup can wait. Attached and late receivers consume that result, while registration rollback preserves its failure cause. Capture the registration's original cancellation context so late notifications cannot cancel a reused process. Genuine execution errors, request cancellation, and connection failures remain errors; the existing End/Error wire format is unchanged. Add deterministic tests for completion before/after attachment, waiter cleanup, rollback, cancellation, and process reuse. The SQL regression uses the original recursive query with small synthetic tables and patched statistics, and checks that remote receiver attachment actually occurs. Validation on commit `9bc213ea37`: - Same SQL regression on clean main `3d67664696`: fails on the first empty-result query with the matching 20101 error. - Fixed SQL regression: passes all nine queries across the 500-row, zero-row, and restored 500-row phases on the shared multi-CN cluster (14.2 seconds including startup). - Full `pkg/sql/colexec`, `pkg/sql/colexec/dispatch`, and `pkg/sql/compile` test suites pass normally and under `-race` using the repository CGo wrapper. - Eight focused lifecycle/concurrency tests each pass 100 repetitions under `-race`. - CI follow-up `14595165fa`: close each SQL result set with a scoped defer; the SQL regression and focused `sqlclosecheck`/`rowserrcheck` validation pass locally. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…atrixorigin#28326) ## 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#28313 ## What this PR does / why we need it: An empty recursive join build can finish a preregistered dispatch before its remote receiver attaches. Normal pipeline cleanup cancels the local context, and a late notify incorrectly turns that cancellation into `Error 20101: internal error: convert go error to mo error context canceled` instead of returning an empty result. Publish an immutable terminal result for each dispatch registration before cleanup can wait. Attached and late receivers consume that result, while registration rollback preserves its failure cause. Capture the registration's original cancellation context so late notifications cannot cancel a reused process. Genuine execution errors, request cancellation, and connection failures remain errors; the existing End/Error wire format is unchanged. Add deterministic tests for completion before/after attachment, waiter cleanup, rollback, cancellation, and process reuse. The SQL regression uses the original recursive query with small synthetic tables and patched statistics, and checks that remote receiver attachment actually occurs. Validation on commit `9bc213ea37`: - Same SQL regression on clean main `3d67664696`: fails on the first empty-result query with the matching 20101 error. - Fixed SQL regression: passes all nine queries across the 500-row, zero-row, and restored 500-row phases on the shared multi-CN cluster (14.2 seconds including startup). - Full `pkg/sql/colexec`, `pkg/sql/colexec/dispatch`, and `pkg/sql/compile` test suites pass normally and under `-race` using the repository CGo wrapper. - Eight focused lifecycle/concurrency tests each pass 100 repetitions under `-race`. - CI follow-up `14595165fa`: close each SQL result set with a scoped defer; the SQL regression and focused `sqlclosecheck`/`rowserrcheck` validation pass locally. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28313
What this PR does / why we need it:
An empty recursive join build can finish a preregistered dispatch before its remote receiver attaches. Normal pipeline cleanup cancels the local context, and a late notify incorrectly turns that cancellation into
Error 20101: internal error: convert go error to mo error context canceledinstead of returning an empty result.Publish an immutable terminal result for each dispatch registration before cleanup can wait. Attached and late receivers consume that result, while registration rollback preserves its failure cause. Capture the registration's original cancellation context so late notifications cannot cancel a reused process. Genuine execution errors, request cancellation, and connection failures remain errors; the existing End/Error wire format is unchanged.
Add deterministic tests for completion before/after attachment, waiter cleanup, rollback, cancellation, and process reuse. The SQL regression uses the original recursive query with small synthetic tables and patched statistics, and checks that remote receiver attachment actually occurs.
Validation on commit
9bc213ea37:3d67664696: fails on the first empty-result query with the matching 20101 error.pkg/sql/colexec,pkg/sql/colexec/dispatch, andpkg/sql/compiletest suites pass normally and under-raceusing the repository CGo wrapper.-race.14595165fa: close each SQL result set with a scoped defer; the SQL regression and focusedsqlclosecheck/rowserrcheckvalidation pass locally.