Repository navigation
fix(pipeline): preserve late remote terminal errors - #28278
Conversation
a2e03b0 to
167bc74
Compare
|
Unrelated CI blocker: coverage UT intermittently failed the pre-existing CDC writer-first task-row lock waiter assertion. Tracked in #28282. The one permitted failed-job rerun for workflow run 34024743134 was requested after attempt 1 became terminal. |
167bc74 to
2f53d8f
Compare
e7810e7 to
14d60b4
Compare
|
@XuPeng-SH Valid and fixed in
I added the full 2×3 cross-product: query cancellation and deadline, each with StopSending send failure, response-channel closure, and timeout. All six failed before the production change with the teardown error, then passed after it. The complete arbitration matrix passed |
XuPeng-SH
left a comment
There was a problem hiding this comment.
The latest RemoteRun change correctly closes the previous query-cancellation/StopSending finding, and the earlier terminal-less and double-wait findings remain fixed. Two equivalent arbitration gaps remain in the local multi-input receiver path.
[P1] Preserve query-owned cancellation before consulting durable edge failures
PipelineSignalReceiver is initialized with only proc.Ctx, so contextDoneError cannot distinguish external query cancellation from internal pipeline cancellation. After plain context.Canceled, it scans the edges and returns any recorded error (process_spoolr.go:522-537). A concrete production-shaped sequence is: build pipelineCtx as a child of queryCtx, initialize a Merge receiver, cancel queryCtx, then let an input edge record a late duplicate-key error before the receiver wakes. Whether GetNextBatch selects the context, Ch2, or Done branch, it returns the duplicate error. normalizeScopeRunError then short-circuits at compile.go:744-746 because the error is substantive, and Compile.Run returns the runOnce error before checking GetQueryContextError (compile2.go:467-470). The client sees duplicate-key instead of the query-owned context.Canceled, contradicting the existing plain external cancellation remains primary contract and the new RemoteRun policy.
Please make receiver arbitration query-aware: when the query context is already canceled/deadlined, preserve that external terminal; consult process causes and durable edges only while the query remains active. Add a deterministic cross-layer test with separate query and pipeline contexts, query cancellation first, and a late durable edge failure.
[P1] Do not let the first cancellation-shaped edge hide a later execution failure
When the query is active and the pipeline context is internally canceled, contextDoneError returns the first non-nil reg.Err() in source order. With two ready inputs where edge 0 records QueryInterrupted/context cancellation and edge 1 records DuplicateEntry, the helper returns edge 0 without examining edge 1. The caller can then normalize that cancellation to nil, recreating the false-success class this PR is intended to eliminate. Reversing the edge order changes the result, even though the terminal facts are identical.
Please inspect all durable edge errors and prefer a substantive execution error over cancellation-only fallout; retain a cancellation error only when every recorded error is cancellation-shaped. Cover both edge orders, preferably with the data channel occupied so the durable-state fallback rather than successful enqueue is the oracle.
2b102a4 to
9bc9c3a
Compare
|
@XuPeng-SH Both findings were valid and are addressed in
The new Merge-level test uses separate query/pipeline contexts, cancels or deadlines the query before recording a late undeliverable DuplicateEntry, and requires the query terminal through the real Focused receiver and Merge cases passed 100 repetitions under |
XuPeng-SH
left a comment
There was a problem hiding this comment.
The previous receiver-arbitration findings are fixed on 3d829006a384, and the exact-head CI evidence is green. One error-precedence cross-product still blocks the PR.
[P1] Preserve an already-known pipeline execution cause over StopSending teardown failures
RemoteRun replaces the cancellation-shaped receive error with every non-nil StopSending result whenever the query context is still active. That replacement happens before normalizeScopeRunError can recover a substantive context.Cause(s.Proc.Ctx). Because BackendClosed, StreamClosed, and RPCTimeout are not cancellation-shaped, normalization then returns early and the cleanup transport error hides the execution failure that originally canceled the pipeline.
A deterministic extension of the existing table reproduces this with:
cancelCause: duplicateErr,
stopSendErr: moerr.NewBackendClosedNoCtx(),
wantErr: duplicateErr,The exact focused run fails with:
expected: Duplicate entry 1 for key primary
in chain: backend connection closed
This is production-reachable when one local scope records a duplicate-key or other substantive failure in the shared pipeline cancellation cause while a remote scope wakes with QueryInterrupted, then its StopSending transport fails during teardown. The client receives a reconnect/retry-shaped transport error instead of the deterministic SQL execution error, and the retained root edge receives the same wrong terminal. Response-channel closure and timeout have the identical precedence defect.
Please resolve the original cancellation through its query/pipeline context before applying the handshake result, or otherwise arbitrate teardown errors only when no query-owned or substantive pipeline-owned terminal already exists. Add the three cross-products of a substantive pipeline cause with StopSending send failure, response closure, and timeout; retain the current behavior where those handshake failures are substantive for a cause-less internal cancellation.
The one-attempt timeout bound, query cancel/deadline priority, receiver edge-order handling, root publication ordering, resource ownership, and steady-state performance path otherwise close correctly in this head.
|
@XuPeng-SH Valid and fixed in
I added all three DuplicateEntry pipeline-cause cross-products. Before the production change they returned BackendClosed, StreamClosed, and RPCTimeout respectively; afterward they return DuplicateEntry at both |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 1e1fbaa against base 6e5f82f.
The latest change closes the remaining precedence blocker: RemoteRun resolves the original query/pipeline cancellation before consulting StopSending, so a substantive execution cause cannot be replaced by BackendClosed, StreamClosed, or RPCTimeout. The new cross-product covers all three teardown outcomes while cause-less internal cancellation still fails closed.
I rechecked the full change map and unhappy paths: StopSending has one owner and one bounded wait; the root durable terminal is published before cancellation; Merge separates query and pipeline contexts and prefers substantive durable edge errors independent of edge order; cleanup adds no retry, goroutine, unbounded queue, or steady-state RPC. The only new O(live inputs) scan is on cancellation/error arbitration, not the data path. Current-head UT/SCA and Proxy/PESSIMISTIC BVT are green. No blocking correctness, liveness, resource, performance, compatibility, or test-quality issue remains.
Merge Queue Status
This pull request spent 19 seconds in the queue, including 4 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Related to #28277
What this PR does / why we need it:
Root cause
A remote pipeline receive can observe internal context cancellation immediately before the execution CN publishes its terminal response. That cancellation was normalized as a successful early stop. The existing StopSending cleanup handshake subsequently consumed the remote terminal error but discarded it. At the local pipeline boundary, scope cancellation could also win before a retained connector Error terminal was observed, even though the PipelineEdge had already recorded the substantive failure durably.
The local multi-input receiver had two related arbitration gaps: it knew only the pipeline context and therefore could replace a query-owned cancellation with a late edge failure, and it returned the first durable edge error in source order even when that error was cancellation fallout and a later edge held the real execution failure. Together these races allowed an execution-side duplicate-key failure to reach the SQL client as success or allowed the wrong terminal class to win.
Remote StopSending arbitration also initially applied its teardown result before resolving the cancellation that triggered cleanup. When the pipeline already carried a substantive execution cause, a simultaneous StopSending send failure, response closure, or timeout could therefore replace that SQL error with a transport error.
Changes
Issue-to-test proof
TestRemoteRunNormalizesPipelineCancellationCause/remote_failure_returned_after_internal_cancellation_survivesdeterministically forces cancellation to win the first receive and releases the duplicate-key terminal only after StopSending. The test failed before the handshake return-value change and now requires the duplicate-key error at bothRemoteRunand the retained root edge.RemoteRunand the retained root while preserving substantive handshake failures for internal cancellation.RemoteRunand the retained root. The existing cause-less cases continue to require the teardown errors.TestPipelineSignalReceiverCancellationPreservesExecutionCause,TestPipelineSignalReceiverCancellationPreservesDeadlineClass, andTestPipelineSignalReceiverCancellationPreservesDurableEdgeFailurecover substantive process causes, joined errors, graceful cancellation, deadline identity, full-channel Error delivery, and QueryInterrupted cancellation.TestPipelineSignalReceiverDurableFailureSelectionIsOrderIndependentfills both input channels so Error publication can succeed only through durable edge state, then proves DuplicateEntry outranks QueryInterrupted in both edge orders and that an all-cancellation set remains cancellation-shaped. Its cancellation-first case failed before the production change.TestMergePreservesQueryTerminalOverLateEdgeFailureuses separate query and pipeline contexts through the real MergePrepare/Callpath. It cancels or deadlines the query before recording an undeliverable late DuplicateEntry and requires the query terminal in both cases. The cancellation case failed before the production change.comprimary_key.sqlstill requires the exact duplicate errors forcpk_table_5andcpk_table_6, and now proves failure atomicity by requiring four rows after each rejectedINSERT ... SELECT.Tests run
make buildon committed head1e1fbaaf691e1fbaaf69under-race, 100 repetitions; the three new pipeline-cause/StopSending cross-products also passed independently-race, 100 repetitions./pkg/sql/compilenormal and race suites on committed head1e1fbaaf69; full affected-package tests on rebased predecessor3d829006a3:./pkg/vm/process,./pkg/sql/colexec/merge, and./pkg/sql/compile./pkg/vm/processand./pkg/sql/colexec/merge./pkg/sql/colexec/connectorand./pkg/sql/colexec/dispatchgo vet -mod=readonly ./pkg/sql/compileon committed head1e1fbaaf69; earlier full affected-package vet remains greengolangci-lint2.6.2 on all three changed package trees at3d829006a3: 0 issues.gofmt -dis empty for every changed Go file on1e1fbaaf69.comprimary_key.sql, 300 repetitions, 21,900/21,900 statements passed; all generated reports were inspected and contained no failures. After review and rebases, the case was repeatedly rerun on fresh two-CN Proxy clusters. On semantic head9bc9c3ae60, it passed 73/73 statements with an empty error report; the six-column duplicate was client-visible and the post-failure row count remained four. The subsequent commit changes only test whitespace.The documented Docker topology could not be built locally because Docker Hub authentication returned EOF. The same repository
etc/launch-with-proxytwo-CN topology was run natively through Proxy with the rebuiltmo-service; no topology configuration is included in this PR.Rebase verification
Rebased onto main commit
6e5f82f568. The new upstream commit changes JSON binary subtype handling and does not overlap this PR's production code, terminal tests, or BVT. The full receiver, Merge, and compile package suites plus repository-configured lint were rerun after rebase. The exact two-CN Proxycomprimary_key.sqlBVT passed 73/73 with an empty error report at9bc9c3ae60; the later3d829006a3commit changed only test formatting. The final RemoteRun precedence change is covered by exact deterministic UT and a committed-head binary build, while fresh PR CI supplies the current-head Proxy BVT.Residual risks
The original CI symptom is timing-dependent. Forced unit tests provide deterministic coverage of cancellation-before-terminal ordering, terminal-less StopSending outcomes, query-vs-pipeline-vs-teardown ownership, and multi-edge priority independent of source order, while repeated Proxy BVT supplies end-to-end stress evidence. Terminal-less StopSending paths fail closed with explicit transport/protocol/timeout errors and have a single bounded wait; no retry, fallback channel, or unbounded resource lifecycle was added.