Repository navigation
fix(dispatch): preserve terminal errors on receiver retirement - #28539
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 live head 3de09ade64b96bcc4374819ef6371aba0cace35e against base 7c643f469b9162dec19b7f880e4cf6b2c12507d9. COMMENT only for this self-authored PR. No concrete blocker found in the changed dispatch retirement and terminal-ownership paths.
The important distinction is preserved: a live StopSending certificate permits consumer-owned retirement; an unqualified ReceiverDone or transport failure still fails strict dispatch. The certificate checks source, message and connection cancellation, and a prior substantive batch-flow failure cannot be retroactively certified by StopSending. Removing a matched remote receiver decrements the counters and revisits the shifted slice element, so other matched receivers still receive the batch. The final remote-only retirement and local spool termination now propagate queryDone.
Terminal-backed registrations have no competing Err channel. Reset publishes the immutable generation terminal before cleanup, including after wrappers have been removed; the registration handler still observes connection/message cancellation and cancels that generation independently. Legacy registrations retain their nonblocking Err notification. This is an ordinary correctness fix within the existing generation protocol, with no wire/catalog change or new design gate.
| Unhappy-path contract | Review result |
|---|---|
| Q1 ownership | One generation terminal publishes through sync.Once; retirement does not take ownership of query success, and Reset still owns terminal completion. |
| Q2 liveness | Removing the compatibility channel does not remove handler cancellation exits; terminal publication precedes cleanup that could wait on receivers. No new blocking primitive or lock order was introduced. |
| Q3 bounds/performance | Retained state remains bounded by registered receivers; removal uses the existing slice/counter path. The outcome value adds no per-batch heap ownership, and terminal-backed registrations avoid an error-channel allocation. |
The deleted 515-line file primarily repeated strict ReceiverDone assertions and narrative-only scenarios; their executable strict/tolerant oracles remain in dispatch_test.go, alongside certified retirement, next-matched-receiver delivery, terminal error, cancellation-certificate, and local termination checks. A useful nonblocking follow-up is a handler-level test using PutProcIntoUuidMapWithTerminal that retires a receiver, then finishes the terminal with DuplicateEntry, asserting the handler returns that exact error and has no legacy channel; the existing after-attach cancellation test uses the legacy registration helper.
git diff --check passed. The PR reports focused normal/race package and issue-regression validation; I did not duplicate the long runs. Ubuntu UT remains in progress, and the exact multi-CN BVT is explicitly not locally validated, so this review does not claim completed CI or new end-to-end evidence.
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #28378 ## What this PR does / why we need it: Add regression coverage for queued stream cancellation, shuffle receiver retirement, and distributed IVF query cleanup. Production fixes are already present through #28358, the relevant dispatch/remote pipeline changes in #28364, and #28539; this PR changes tests only and does not establish their individual causal contribution to the original TKE incident. - Observe serialized MORPC sequence numbers after a queued message is canceled. The identical test compiles on the #28358 parent and fails with expected sequence 2 versus actual 3. - Cover first, middle, last, and consecutive shuffle receiver retirement, checking both subsequent sends and one-time notification. Exercise query/connection cancellation during real receiver credit waiting through the CN handler, preserving the terminal error and releasing lifecycle registration. - Add a two-CN IVF test with 256 128-dimensional vectors. The representative L2 case exercises eight concurrent sessions with one simultaneous query per session; cosine, normalized L2, and raw-vector IP/normalized-query retain their per-distance lifecycle and result checks. The test covers exact full-probe comparison, approximate-result validity, empty results, and subsequent queries. Test preparation failure uses the actual phase runner, transaction rollback, worker exit, and database cleanup. Preparation and query budgets are cumulative but separate; cleanup gets its own context. SQL pre-cancellation is not presented as proof of active remote cancellation. The fixture provides 16 vectors per IVF list on average; Vector Index Scan selects Multi-CN without a 65,536-row threshold, so the 256-row fixture preserves the lifecycle and result oracles while bounding the owning package's race cost. - Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and .result with cosine, raw-vector IP/normalized-query, empty-result, and follow-up checks. The GROUP_CONCAT metadata expectation uses the existing server TEXT mapping and Connector/J 8.0.15 metadata; results were not regenerated blindly. Validation (final file contents include the follow-up assertion, SCA, coverage-budget, fixture-size, and concurrency-budget fixes; exact head 323daee; upstream base 07b2596; product base 2a6fe7f): - macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test package parallelism 1. - New mechanism tests: ordinary 100 iterations and race 20 iterations passed. MORPC, dispatch, and compile packages passed ordinary/race checks; unchanged evidence was reused. - Follow-up P2 validation: TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed ordinary 100 iterations and race 20 iterations after asserting that connection cancellation closes proc.Ctx, records a non-nil ErrStreamClosed cause, and preserves it through repeated terminal cleanup. - After the follow-up edit, the complete owning ./pkg/sql/compile package passed once under the race detector; no race report was emitted. - Exact prior-head fixture validation: GOWORK=off go test -mod=readonly -count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$' ./pkg/tests/issues passed in 14.855s; the same exact test with -race and a 20m timeout passed in 34.817s. After the first fixture-size change, the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after the final 256-row/one-iteration change, it passed ordinary in 16.591s and race in 24.467s. - The MORPC parent counterexample validates the sequence mechanism. The IVF integration test is regression coverage, not a deterministic reproduction of the historical incident. - Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows and the concurrent repeat count from two to one in 323daee. XuPeng-SH measured the prior 65,536-row test at 573.55s in the exclusive -p 1 -race UT stage on parent head 7944a5b; the focused runs above measure the latest local fixture at 16.591s ordinary and 24.467s race. These are different environments and modes, so the numbers are reported as bounded before/after evidence rather than a CI performance claim. The exact-head CI run below provides the Linux cost measurement. - Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required. The subsequent exact-head run 34799486791 for 323daee passed on attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, Coverage, and CI Required are green. Its first attempt failed only in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay expired before I/O complete`; the failed Coverage chain passed on rerun without code changes. - Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36 comparisons with full metadata checking. go vet, gofmt, and diff checks passed. Deployment evidence for the already-fixed product base, independently of this new test commit: - Old baseline run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993: HNSW/L2/cosine/normalize errors were 0/1702/1266/588. - Fixed-product run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049: all four original million-vector SIFT128 cases completed with 100 terminals, five-minute measurements, and zero client errors. The five data hashes match the failed baseline. Acceptance was checked from artifact counters and error files, not only workflow success. QA required: yes — distributed timing and deployed-workload acceptance. Automated terminal coverage includes completed SQL assertions, cancellation waiter exit, preserved terminal errors, registration removal, and cleanup. QA should review the target release's inclusion of the existing production fixes and the attached run evidence. First-error query/stream/peer correlation and unique root-cause attribution remain unavailable; this PR must not auto-close #28378. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…xorigin#28539) ## Summary Fix the distributed dispatch race behind matrixorigin#28313 and the `shuffle target receiver ... was removed, data loss may occur` failure seen in matrixorigin#28513 CI. A receiver that explicitly sends `StopSending` is a consumer-owned retirement. The previous implementation collapsed that control signal into generic receiver removal, synthesized a data-loss error, and allowed the legacy `Err` channel to compete with the immutable remote terminal. That could mask the original business error (for example, `DuplicateEntry`) and produce cleanup warnings such as `channel full`. This change: - preserves one terminal owner per receiver generation; - treats only a certified `StopSending` as normal retirement; - keeps unqualified receiver/transport termination fail-closed in strict dispatch paths; - lets shuffle dispatch continue across other matched receivers after an explicit retirement; - keeps legacy `Err` notification only for registrations without a terminal; - removes the obsolete 515-line low-value integration test and keeps focused strict, tolerant, cancellation, terminal, and shuffle oracles. ## Validation - `go test ./pkg/sql/colexec/dispatch -count=1` - `go test -race ./pkg/sql/colexec/dispatch -count=10` - `go test ./pkg/sql/compile -count=1` - `go test -race ./pkg/sql/compile -count=1` - `go test ./pkg/sql/colexec -count=1` - `go test ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1` - `go test -race ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1` - `go vet ./pkg/sql/colexec/dispatch ./pkg/sql/compile` The focused validation used the repository's installed CGo headers and libraries. The exact multi-CN BVT requires the CI cluster topology and was not run locally. Closes matrixorigin#28313 --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28378 ## What this PR does / why we need it: Add regression coverage for queued stream cancellation, shuffle receiver retirement, and distributed IVF query cleanup. Production fixes are already present through matrixorigin#28358, the relevant dispatch/remote pipeline changes in matrixorigin#28364, and matrixorigin#28539; this PR changes tests only and does not establish their individual causal contribution to the original TKE incident. - Observe serialized MORPC sequence numbers after a queued message is canceled. The identical test compiles on the matrixorigin#28358 parent and fails with expected sequence 2 versus actual 3. - Cover first, middle, last, and consecutive shuffle receiver retirement, checking both subsequent sends and one-time notification. Exercise query/connection cancellation during real receiver credit waiting through the CN handler, preserving the terminal error and releasing lifecycle registration. - Add a two-CN IVF test with 256 128-dimensional vectors. The representative L2 case exercises eight concurrent sessions with one simultaneous query per session; cosine, normalized L2, and raw-vector IP/normalized-query retain their per-distance lifecycle and result checks. The test covers exact full-probe comparison, approximate-result validity, empty results, and subsequent queries. Test preparation failure uses the actual phase runner, transaction rollback, worker exit, and database cleanup. Preparation and query budgets are cumulative but separate; cleanup gets its own context. SQL pre-cancellation is not presented as proof of active remote cancellation. The fixture provides 16 vectors per IVF list on average; Vector Index Scan selects Multi-CN without a 65,536-row threshold, so the 256-row fixture preserves the lifecycle and result oracles while bounding the owning package's race cost. - Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and .result with cosine, raw-vector IP/normalized-query, empty-result, and follow-up checks. The GROUP_CONCAT metadata expectation uses the existing server TEXT mapping and Connector/J 8.0.15 metadata; results were not regenerated blindly. Validation (final file contents include the follow-up assertion, SCA, coverage-budget, fixture-size, and concurrency-budget fixes; exact head 323daee; upstream base 07b2596; product base 2a6fe7f): - macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test package parallelism 1. - New mechanism tests: ordinary 100 iterations and race 20 iterations passed. MORPC, dispatch, and compile packages passed ordinary/race checks; unchanged evidence was reused. - Follow-up P2 validation: TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed ordinary 100 iterations and race 20 iterations after asserting that connection cancellation closes proc.Ctx, records a non-nil ErrStreamClosed cause, and preserves it through repeated terminal cleanup. - After the follow-up edit, the complete owning ./pkg/sql/compile package passed once under the race detector; no race report was emitted. - Exact prior-head fixture validation: GOWORK=off go test -mod=readonly -count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$' ./pkg/tests/issues passed in 14.855s; the same exact test with -race and a 20m timeout passed in 34.817s. After the first fixture-size change, the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after the final 256-row/one-iteration change, it passed ordinary in 16.591s and race in 24.467s. - The MORPC parent counterexample validates the sequence mechanism. The IVF integration test is regression coverage, not a deterministic reproduction of the historical incident. - Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows and the concurrent repeat count from two to one in 323daee. XuPeng-SH measured the prior 65,536-row test at 573.55s in the exclusive -p 1 -race UT stage on parent head 7944a5b; the focused runs above measure the latest local fixture at 16.591s ordinary and 24.467s race. These are different environments and modes, so the numbers are reported as bounded before/after evidence rather than a CI performance claim. The exact-head CI run below provides the Linux cost measurement. - Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required. The subsequent exact-head run 34799486791 for 323daee passed on attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, Coverage, and CI Required are green. Its first attempt failed only in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay expired before I/O complete`; the failed Coverage chain passed on rerun without code changes. - Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36 comparisons with full metadata checking. go vet, gofmt, and diff checks passed. Deployment evidence for the already-fixed product base, independently of this new test commit: - Old baseline run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993: HNSW/L2/cosine/normalize errors were 0/1702/1266/588. - Fixed-product run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049: all four original million-vector SIFT128 cases completed with 100 terminals, five-minute measurements, and zero client errors. The five data hashes match the failed baseline. Acceptance was checked from artifact counters and error files, not only workflow success. QA required: yes — distributed timing and deployed-workload acceptance. Automated terminal coverage includes completed SQL assertions, cancellation waiter exit, preserved terminal errors, registration removal, and cleanup. QA should review the target release's inclusion of the existing production fixes and the attached run evidence. First-error query/stream/peer correlation and unique root-cause attribution remain unavailable; this PR must not auto-close matrixorigin#28378. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…xorigin#28539) ## Summary Fix the distributed dispatch race behind matrixorigin#28313 and the `shuffle target receiver ... was removed, data loss may occur` failure seen in matrixorigin#28513 CI. A receiver that explicitly sends `StopSending` is a consumer-owned retirement. The previous implementation collapsed that control signal into generic receiver removal, synthesized a data-loss error, and allowed the legacy `Err` channel to compete with the immutable remote terminal. That could mask the original business error (for example, `DuplicateEntry`) and produce cleanup warnings such as `channel full`. This change: - preserves one terminal owner per receiver generation; - treats only a certified `StopSending` as normal retirement; - keeps unqualified receiver/transport termination fail-closed in strict dispatch paths; - lets shuffle dispatch continue across other matched receivers after an explicit retirement; - keeps legacy `Err` notification only for registrations without a terminal; - removes the obsolete 515-line low-value integration test and keeps focused strict, tolerant, cancellation, terminal, and shuffle oracles. ## Validation - `go test ./pkg/sql/colexec/dispatch -count=1` - `go test -race ./pkg/sql/colexec/dispatch -count=10` - `go test ./pkg/sql/compile -count=1` - `go test -race ./pkg/sql/compile -count=1` - `go test ./pkg/sql/colexec -count=1` - `go test ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1` - `go test -race ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1` - `go vet ./pkg/sql/colexec/dispatch ./pkg/sql/compile` The focused validation used the repository's installed CGo headers and libraries. The exact multi-CN BVT requires the CI cluster topology and was not run locally. Closes matrixorigin#28313 --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28378 ## What this PR does / why we need it: Add regression coverage for queued stream cancellation, shuffle receiver retirement, and distributed IVF query cleanup. Production fixes are already present through matrixorigin#28358, the relevant dispatch/remote pipeline changes in matrixorigin#28364, and matrixorigin#28539; this PR changes tests only and does not establish their individual causal contribution to the original TKE incident. - Observe serialized MORPC sequence numbers after a queued message is canceled. The identical test compiles on the matrixorigin#28358 parent and fails with expected sequence 2 versus actual 3. - Cover first, middle, last, and consecutive shuffle receiver retirement, checking both subsequent sends and one-time notification. Exercise query/connection cancellation during real receiver credit waiting through the CN handler, preserving the terminal error and releasing lifecycle registration. - Add a two-CN IVF test with 256 128-dimensional vectors. The representative L2 case exercises eight concurrent sessions with one simultaneous query per session; cosine, normalized L2, and raw-vector IP/normalized-query retain their per-distance lifecycle and result checks. The test covers exact full-probe comparison, approximate-result validity, empty results, and subsequent queries. Test preparation failure uses the actual phase runner, transaction rollback, worker exit, and database cleanup. Preparation and query budgets are cumulative but separate; cleanup gets its own context. SQL pre-cancellation is not presented as proof of active remote cancellation. The fixture provides 16 vectors per IVF list on average; Vector Index Scan selects Multi-CN without a 65,536-row threshold, so the 256-row fixture preserves the lifecycle and result oracles while bounding the owning package's race cost. - Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and .result with cosine, raw-vector IP/normalized-query, empty-result, and follow-up checks. The GROUP_CONCAT metadata expectation uses the existing server TEXT mapping and Connector/J 8.0.15 metadata; results were not regenerated blindly. Validation (final file contents include the follow-up assertion, SCA, coverage-budget, fixture-size, and concurrency-budget fixes; exact head 323daee; upstream base 07b2596; product base 2a6fe7f): - macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test package parallelism 1. - New mechanism tests: ordinary 100 iterations and race 20 iterations passed. MORPC, dispatch, and compile packages passed ordinary/race checks; unchanged evidence was reused. - Follow-up P2 validation: TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed ordinary 100 iterations and race 20 iterations after asserting that connection cancellation closes proc.Ctx, records a non-nil ErrStreamClosed cause, and preserves it through repeated terminal cleanup. - After the follow-up edit, the complete owning ./pkg/sql/compile package passed once under the race detector; no race report was emitted. - Exact prior-head fixture validation: GOWORK=off go test -mod=readonly -count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$' ./pkg/tests/issues passed in 14.855s; the same exact test with -race and a 20m timeout passed in 34.817s. After the first fixture-size change, the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after the final 256-row/one-iteration change, it passed ordinary in 16.591s and race in 24.467s. - The MORPC parent counterexample validates the sequence mechanism. The IVF integration test is regression coverage, not a deterministic reproduction of the historical incident. - Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows and the concurrent repeat count from two to one in 323daee. XuPeng-SH measured the prior 65,536-row test at 573.55s in the exclusive -p 1 -race UT stage on parent head 7944a5b; the focused runs above measure the latest local fixture at 16.591s ordinary and 24.467s race. These are different environments and modes, so the numbers are reported as bounded before/after evidence rather than a CI performance claim. The exact-head CI run below provides the Linux cost measurement. - Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required. The subsequent exact-head run 34799486791 for 323daee passed on attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, Coverage, and CI Required are green. Its first attempt failed only in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay expired before I/O complete`; the failed Coverage chain passed on rerun without code changes. - Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36 comparisons with full metadata checking. go vet, gofmt, and diff checks passed. Deployment evidence for the already-fixed product base, independently of this new test commit: - Old baseline run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993: HNSW/L2/cosine/normalize errors were 0/1702/1266/588. - Fixed-product run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049: all four original million-vector SIFT128 cases completed with 100 terminals, five-minute measurements, and zero client errors. The five data hashes match the failed baseline. Acceptance was checked from artifact counters and error files, not only workflow success. QA required: yes — distributed timing and deployed-workload acceptance. Automated terminal coverage includes completed SQL assertions, cancellation waiter exit, preserved terminal errors, registration removal, and cleanup. QA should review the target release's inclusion of the existing production fixes and the attached run evidence. First-error query/stream/peer correlation and unique root-cause attribution remain unavailable; this PR must not auto-close matrixorigin#28378. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…xorigin#28539) ## Summary Fix the distributed dispatch race behind matrixorigin#28313 and the `shuffle target receiver ... was removed, data loss may occur` failure seen in matrixorigin#28513 CI. A receiver that explicitly sends `StopSending` is a consumer-owned retirement. The previous implementation collapsed that control signal into generic receiver removal, synthesized a data-loss error, and allowed the legacy `Err` channel to compete with the immutable remote terminal. That could mask the original business error (for example, `DuplicateEntry`) and produce cleanup warnings such as `channel full`. This change: - preserves one terminal owner per receiver generation; - treats only a certified `StopSending` as normal retirement; - keeps unqualified receiver/transport termination fail-closed in strict dispatch paths; - lets shuffle dispatch continue across other matched receivers after an explicit retirement; - keeps legacy `Err` notification only for registrations without a terminal; - removes the obsolete 515-line low-value integration test and keeps focused strict, tolerant, cancellation, terminal, and shuffle oracles. ## Validation - `go test ./pkg/sql/colexec/dispatch -count=1` - `go test -race ./pkg/sql/colexec/dispatch -count=10` - `go test ./pkg/sql/compile -count=1` - `go test -race ./pkg/sql/compile -count=1` - `go test ./pkg/sql/colexec -count=1` - `go test ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1` - `go test -race ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1` - `go vet ./pkg/sql/colexec/dispatch ./pkg/sql/compile` The focused validation used the repository's installed CGo headers and libraries. The exact multi-CN BVT requires the CI cluster topology and was not run locally. Closes matrixorigin#28313 --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28378 ## What this PR does / why we need it: Add regression coverage for queued stream cancellation, shuffle receiver retirement, and distributed IVF query cleanup. Production fixes are already present through matrixorigin#28358, the relevant dispatch/remote pipeline changes in matrixorigin#28364, and matrixorigin#28539; this PR changes tests only and does not establish their individual causal contribution to the original TKE incident. - Observe serialized MORPC sequence numbers after a queued message is canceled. The identical test compiles on the matrixorigin#28358 parent and fails with expected sequence 2 versus actual 3. - Cover first, middle, last, and consecutive shuffle receiver retirement, checking both subsequent sends and one-time notification. Exercise query/connection cancellation during real receiver credit waiting through the CN handler, preserving the terminal error and releasing lifecycle registration. - Add a two-CN IVF test with 256 128-dimensional vectors. The representative L2 case exercises eight concurrent sessions with one simultaneous query per session; cosine, normalized L2, and raw-vector IP/normalized-query retain their per-distance lifecycle and result checks. The test covers exact full-probe comparison, approximate-result validity, empty results, and subsequent queries. Test preparation failure uses the actual phase runner, transaction rollback, worker exit, and database cleanup. Preparation and query budgets are cumulative but separate; cleanup gets its own context. SQL pre-cancellation is not presented as proof of active remote cancellation. The fixture provides 16 vectors per IVF list on average; Vector Index Scan selects Multi-CN without a 65,536-row threshold, so the 256-row fixture preserves the lifecycle and result oracles while bounding the owning package's race cost. - Extend test/distributed/cases/vector/vector_ivf_multicn_search.sql and .result with cosine, raw-vector IP/normalized-query, empty-result, and follow-up checks. The GROUP_CONCAT metadata expectation uses the existing server TEXT mapping and Connector/J 8.0.15 metadata; results were not regenerated blindly. Validation (final file contents include the follow-up assertion, SCA, coverage-budget, fixture-size, and concurrency-budget fixes; exact head 323daee; upstream base 07b2596; product base 2a6fe7f): - macOS arm64, Go 1.26.4, repository CGo wrapper, GOMAXPROCS=4, test package parallelism 1. - New mechanism tests: ordinary 100 iterations and race 20 iterations passed. MORPC, dispatch, and compile packages passed ordinary/race checks; unchanged evidence was reused. - Follow-up P2 validation: TestRemoteNotifyCancellationReleasesCreditWaitAndRegistration passed ordinary 100 iterations and race 20 iterations after asserting that connection cancellation closes proc.Ctx, records a non-nil ErrStreamClosed cause, and preserves it through repeated terminal cleanup. - After the follow-up edit, the complete owning ./pkg/sql/compile package passed once under the race detector; no race report was emitted. - Exact prior-head fixture validation: GOWORK=off go test -mod=readonly -count=1 -timeout=15m -run '^TestIssue28378IVFFlatRemoteLifecycle$' ./pkg/tests/issues passed in 14.855s; the same exact test with -race and a 20m timeout passed in 34.817s. After the first fixture-size change, the 1,024-row test passed ordinary in 16.675s and race in 33.739s; after the final 256-row/one-iteration change, it passed ordinary in 16.591s and race in 24.467s. - The MORPC parent counterexample validates the sequence mechanism. The IVF integration test is regression coverage, not a deterministic reproduction of the historical incident. - Reviewer P2 response: the fixture was reduced from 65,536 to 256 rows and the concurrent repeat count from two to one in 323daee. XuPeng-SH measured the prior 65,536-row test at 573.55s in the exclusive -p 1 -race UT stage on parent head 7944a5b; the focused runs above measure the latest local fixture at 16.591s ordinary and 24.467s race. These are different environments and modes, so the numbers are reported as bounded before/after evidence rather than a CI performance claim. The exact-head CI run below provides the Linux cost measurement. - Exact current-head CI run 34756863153 for f7cb131 passed Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, and CI Required. The subsequent exact-head run 34799486791 for 323daee passed on attempt 2: Ubuntu UT, SCA, UT Coverage, shared build, Proxy/Pessimistic BVT, Coverage, and CI Required are green. Its first attempt failed only in the unrelated optools TestUTHeartbeatStopsCleanly with `WaitDelay expired before I/O complete`; the failed Coverage chain passed on rerun without code changes. - Formal BVT: CN1 and CN2 JDBC entry points each passed 36/36 comparisons with full metadata checking. go vet, gofmt, and diff checks passed. Deployment evidence for the already-fixed product base, independently of this new test commit: - Old baseline run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34352473993: HNSW/L2/cosine/normalize errors were 0/1702/1266/588. - Fixed-product run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34464342049: all four original million-vector SIFT128 cases completed with 100 terminals, five-minute measurements, and zero client errors. The five data hashes match the failed baseline. Acceptance was checked from artifact counters and error files, not only workflow success. QA required: yes — distributed timing and deployed-workload acceptance. Automated terminal coverage includes completed SQL assertions, cancellation waiter exit, preserved terminal errors, registration removal, and cleanup. QA should review the target release's inclusion of the existing production fixes and the attached run evidence. First-error query/stream/peer correlation and unique root-cause attribution remain unavailable; this PR must not auto-close matrixorigin#28378. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Fix the distributed dispatch race behind #28313 and the
shuffle target receiver ... was removed, data loss may occurfailure seen in #28513 CI.A receiver that explicitly sends
StopSendingis a consumer-owned retirement. The previous implementation collapsed that control signal into generic receiver removal, synthesized a data-loss error, and allowed the legacyErrchannel to compete with the immutable remote terminal. That could mask the original business error (for example,DuplicateEntry) and produce cleanup warnings such aschannel full.This change:
StopSendingas normal retirement;Errnotification only for registrations without a terminal;Validation
go test ./pkg/sql/colexec/dispatch -count=1go test -race ./pkg/sql/colexec/dispatch -count=10go test ./pkg/sql/compile -count=1go test -race ./pkg/sql/compile -count=1go test ./pkg/sql/colexec -count=1go test ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1go test -race ./pkg/tests/issues -run TestIssue28313EmptyRemoteDispatch -count=1go vet ./pkg/sql/colexec/dispatch ./pkg/sql/compileThe focused validation used the repository's installed CGo headers and libraries. The exact multi-CN BVT requires the CI cluster topology and was not run locally.
Closes #28313