Skip to content

fix: preserve execution failures across pipeline cancellation - #29619

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/29588-preserve-execution-failures
Oct 5, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/29588-preserve-execution-failures

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 5, 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:

Addresses #29588's confirmed execution-layer failure-to-success defect. Attribution of the historical Chaos incident remains unverified.

What this PR does / why we need it:

A producer failure after partial input could be normalized into success when sibling cleanup canceled its pipeline. Preserve the producer's frozen failure through terminal publication, nested scopes, remote notifications and statement settlement, while retaining Compile's RC/SI retry policy and concrete public error codes.

Successful consumer retirement also needs to stay control flow. The PROXY BVT metadata query in prepare_ddl_schema_change.sql:112 expected count 0 but returned internal error: pipeline consumer finished: the join-map error snapshot converted the new successful-stop sentinel to a substantive internal error. Snapshot its immutable structural control marker using the existing cancellation representation. The scope still decides success from its exact cancellation cause and live query; declared failures and substantive or independent deadline leaves remain errors. If a consumer stopped before its parent query deadline, preserve the later query deadline rather than returning the stale stop diagnostic.

The complete change closes existing execution owners:

  • Freeze failure provenance and scope outcomes before cleanup. Join producer and late remote errors before statement success; retain retry identity and unwrap only the private provenance envelope at public/wire boundaries.
  • Release local output obligations before remote StopSending waits. Retire only unopened DOP outputs from unsubmitted scope trees; preserve live siblings and normal Reset ownership.
  • Use the existing stream registration/terminal and cancellation registry for stop before registration and attachment, including stream-reuse-disabled mode. Retain waiter references and cancellation callbacks across attachment; retire the subscription without canceling the shared producer or another stream.
  • Arbitrate normal and StopSending terminals in one owner. Preserve explicit remote execution/retry errors ahead of auxiliary decoding failures; reject malformed completion as success and invalidate reuse authorization.
  • Make the existing immutable registration terminal the only dispatch completion owner. Remove registration-lag retry/backoff, terminal-less Err channels, obsolete lookup/forced-delete wrappers and their dedicated tests; migrate conflict/rollback/generation assertions to canonical APIs and require exact-owner cleanup.
  • Bound optional remote teardown at its existing parent owner. Normal notify cleanup and deferred collection share one lazy query-rooted 30-second deadline for Stop fallback and FIN/ACK. Query cancellation skips optional handshakes; only the exact certified local-stop cause can continue successful reuse. Required execution settlement remains independently bounded so cleanup expiration cannot hide late failure or retry. Remove the redundant cleanup-authorization fields and helper.
  • Keep public terminal injection scoped to statement/connection identity. Restore CN settings and clients, join detached forwarding, and leave shared-cluster failure quarantine/destruction with its existing fixture owner. Add independent native SQL overflow and prepared-FK metadata controls using that same two-CN fixture.

No protocol or persistent format changes, new state machine, goroutine, cache, database/network operation or retry layer. The complete cancellation-owner change requires an offline full-cluster upgrade; mixed-version rolling upgrades are not established.

Validation

Final revision: 52facc0f5f0fe4c0b5815d2f71add97748e48d56. Linux/amd64, Go 1.26.4, GOMAXPROCS=8, locally built CPU native artifacts, repository CGo test wrapper.

  • Normal/race proof covers the 19 owning/direct-consumer packages. This follow-up refreshed compile, colexec, dispatch, process, metric registration and the full DML package; unchanged closure evidence from 3980208 is retained. Focused terminal/actual parent/RC retry assertions and migrated registration/rollback/generation/retirement tests passed individually bounded 100-repeat race runs.
  • The same terminal table exercises normal receive and StopSending: valid completion, malformed Analyse, explicit transaction retry, malformed Analyse plus retry, malformed error bytes and closed transport. Invalid responses remain ineligible for FIN/ACK reuse before and after local cleanup, and close the connection exactly once.
  • Real Scope.RemoteRun and remote-notify fixtures release the local consumer before remote settlement and preserve malformed-terminal failures through actual parent collection. An explicit ErrTxnNeedRetry still selects Compile's RC retry policy. Both P2 defects reproduced on the clean merge base before repair.
  • The existing two-CN public SQL fixture now covers 16 targeted terminal faults across reuse enabled/disabled: execution failure, malformed Analyse, and execution failure plus malformed Analyse, including LIMIT paths. MySQL error identity, one-shot targeting, live user context, healthy untargeted queries and continued use of the same SQL connection are asserted. One shared cluster is reused.
  • Original native overflow (MySQL 1690 / SQLSTATE 22003), prepared FK metadata, snapshot, nested partial-input and cleanup controls remain covered. The CI-named prepare_ddl_schema_change.sql passed twice in mo-tester comparison mode (299 statements each); this unchanged exact-case evidence is reused.
  • Complete-delta gofmt/diff checks and 19-package incremental vet, pinned golangci-lint and molint passed. Golangci reports zero new issues. Molint's 13 diagnostics match the verified clean baseline; none were introduced. No threshold, skip or CI lane was weakened.
  • The production-budget virtual-time regressions cover three serial notify results with absent FIN ACKs, optional Stop fallback, Stop followed by FIN, and normal-to-deferred cleanup. They assert 0 seconds of protocol waiting after query cancellation and one 30-second shared budget with a live query, frozen errors and exactly one close per stream. Neighboring ready-ACK/source-cancellation, wrapped/marked stop, query deadline and required late failure/retry cases are included.
  • Fresh normal and race validation covers all six owning packages: colexec, dispatch, compile, process, metric/v2 and tests/dml, including actual two-CN terminal/native SQL controls. Eight affected concurrency tests each passed 100 individually selected race repetitions; no whole-package stress or empty selections are counted.
  • gpt-6.1-sol / xhigh produced the design and reviewed all 47 changed files and the six-file follow-up, including ownership, unhappy paths, performance and test quality. No material code/design blocker remains. Final validation reconciliation is recorded before push.

Performance and limitations

Terminal arbitration uses the existing decoders once and adds no per-row allocation, stored state, goroutine or database/network I/O. Removing notify retry timers/backoff and legacy receiver completion fields/writes reduces lifecycle work. Stream-reuse-disabled mode remains supported. Shared moerr wire identifiers remain unchanged; unsupported terminal-less registrations and retry fallbacks are retired.

Optional teardown uses one temporary context/timer per owning cleanup group instead of a fresh FIN budget per notify sender, with no per-row work or new goroutines. Required Stop settlement remains separately bounded. The 30-second shared limit covers optional protocol waits, not physical backend closure or the entire statement.

Fresh paired two-CN performance validation compared 812aeaa2 with 52facc0f after rebase: 27,648 verified SQL statements across reuse on/off, SUM and early-stop, and 1/8 clients; warm throughput medians ranged from -1.59% to +7.63%. Some small-sample P99 medians rose about 7%, so a bounded ABBA follow-up checked 65,536 more statements in reuse-enabled SUM and reuse-disabled early-stop at 8 clients with 8,192 samples per cell/round. Their P99 changed -8.81% and -7.37%; the apparent tail regression did not reproduce in those measured cells. These local diagnostics establish no stable regression here, not a production throughput/P99 guarantee.

Prior paired snapshot microbenchmarks measured 15 allocations / 717 B before versus 2 allocations / 56 B after; this unchanged evidence is retained, not a new SQL throughput or P99 guarantee. No real TPCC Kill-CN chaos, physical network-corruption reproduction or historical incident attribution is claimed. Native overflow produced zero rows before error; nested white-box tests establish partial-input failure handling.

The branch was cleanly rebased onto upstream main 625404fd7d. Range-diff confirms all eight inherited commits are unchanged; affected binder/readutil consumers were revalidated. The previous PR head 812aeaa2 has no failed CI checks. CI for the new pushed revision is pending and is not claimed successful.

This follow-up: implementation +79/-69 (net +10), tests +216/-98 (net +118), documentation 0. Complete PR: implementation +671/-641 (net +30), tests +2175/-1382 (net +793), documentation 0. No file moves are counted as reductions. The small implementation increase buys a parent-owned resource bound while deleting duplicate reuse authorization; tests cover that bound and preserve independent settlement.

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

@mergify mergify Bot added the kind/bug Something isn't working label Oct 5, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Oct 5, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 812aeaa2b7d6077be7a0f478323d7fdeb5c9efb4 against merge-base 43c37847b16d37cfa8b9eef4235ba4388b5e25ce. No subagents, no product edits, no CI wait.

Decision: no verified merge-blocking finding in this review. This is a self-authored PR, so this COMMENT is not an independent APPROVE.

Design/ownership: the fix restores the existing distinction between an execution failure, external query cancellation and successful fragment Stop. Scope/Compile still own outcome arbitration; immutable JoinMap snapshots own published errors; the existing generation-specific registration/terminal and cancel registry own remote settlement. There is no second state machine, retained outcome cache, persistence format or wire-field change. RC retry precedence and SI first-failure policy remain explicit. This is a corrective fix/cleanup, not a new capability requiring a feature design document.

Read and traced all 47 changed files: failure markers/public unwrapping, Pipeline and Scope cleanup, nested/parallel result collection, immutable JoinMap snapshots, normal/Stop terminal decoding and fail-closed reuse, registry waiter/attachment/generation cleanup, reuse-disabled subscription cancellation, dispatch rollback, the retired retry metric and test-fixture ownership. Substantive declared Error, an independent deadline and late retry cannot be turned into success by cleanup; normal Stop does not cancel a shared producer or surviving subscriber. Local terminal publication precedes bounded remote settlement. Exact-owner deletion prevents a stale generation from deleting its replacement.

Independent validation on this head, Go 1.26.4 darwin/arm64, CPU CGo rebuilt through the top-level owner with verified dependencies:

  • Ten targeted compile test roots: normal and race PASS; four additional separate-process race repetitions PASS (floor(30/6.084)=4, not cached/in-process repetition).
  • Complete compile, process, colexec, dispatch and vm/message packages: race PASS, terminal command exit 0.
  • Real two-CN public SQL contract, both connection-reuse settings: injected failure after partial input, healthy untargeted/request-isolation controls, forwarder close, actual overflow error 1690/22003, and prepared FK metadata cleanup: all five selected DML roots race PASS. Public injected failure/FK cases also passed normally.
  • Unchanged adjacent TestIssue29492MultiCNCancellationCleanup: race PASS (17.10s test / 19.575s package), challenging cancellation/teardown independently of the new fixture.
  • Diff whitespace check PASS. Initial missing-native and mistaken package-selection attempts are not counted as product failures or passing validation; corrected commands above reached terminal success.

Historical comment disposition: read all three prior COMMENT reviews; there are no human inline findings. Earlier no-wait-cycle reasoning is superseded by the explicit current local-terminal-before-remote-wait ordering. Latest terminal/registration changes were revalidated rather than inheriting stale passes. Obsolete Err-channel/backoff/forced-delete tests were retired with their implementations; conflict, rollback, terminal, generation, DOP/lazy-branch and shared-owner behavior remain tested at the canonical owners.

Engineering/performance: production +597/-577, tests +1985/-1310, docs zero. The test increment is justified by distinct failure/provenance/reuse/ownership contracts rather than repeated setup; real overflow/FK controls do not use the injector as their oracle. Failure provenance is error-path work; terminal decoding is shared rather than repeated, and removed retry/channel bookkeeping is not replaced by another retained structure. No fresh throughput benchmark, TPCC/Kill-CN incident reproduction, GPU/Linux runtime validation or universal “no regression” claim is made. Stored data/offline upgrade semantics are unchanged; mixed-version rolling upgrade is outside this review. Local evidence: /private/tmp/mo-review-five.HHHg3U/29619-*.log.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review of commit 52facc0f5f0fe4c0b5815d2f71add97748e48d56 covering design, ownership, unhappy paths, performance, and implementation/test quality. No subagents were used.

No new blocking P1/P2 defect was confirmed. One nonblocking P3 cleanup omission remains. Required CI is still pending; this review does not establish an all-green merge gate.

[P3] Remove the unused constructor left by the retired registration-retry protocol.

pkg/common/moerr/error.go:1078 still defines NewRemoteDispatchNotRegistered. This PR removes its only production caller (newRemoteDispatchNotRegisteredYetError), the classifier, TryGetProcByUuid, and the notification retry path. A repository-wide symbol search now finds only the constructor definition, numeric constant, and error catalog entry. Delete the unused constructor so the callable API no longer advertises the retired protocol. Preserve numeric error-code allocation; do not renumber unrelated codes. This is a maintenance issue, not a current execution or performance failure.

Historical review concerns were checked against the current owners and retained behavior tests: failure provenance and nested RC retry, local/remote teardown ordering and late failure collection, unstarted DOP retirement, registration-generation cancellation, StopSending with reuse disabled, request-scoped fault injection, and shared fixture cleanup. Their fixes are present in this commit.

Audit Result
Ownership Generation terminals and owner-scoped registration cleanup replace parallel error channels; stream close remains guarded by closeOnce.
Wait termination Local consumers are released before required remote settlement. Optional Stop/FIN cleanup shares one query-rooted budget; required settlement retains independent authority. This is not a whole-query or physical-close 30-second guarantee.
Retained state UUID registrations and waiter references have reachable generation-specific release; result queues are bounded by admitted work. No unbounded retention was demonstrated in the changed paths.
Test quality Tests cover public SQL error codes, partial-result failure, cancellation, reuse on/off, and healthy queries on the same connection. Retired retry-only tests and duplicate fixture destruction were removed.

Validation reuse was checked against the exact complete patch fingerprint: 22c302d8bfdde53e287415a31abe564ca5cebcdbcf6829b7a8bc97f2c535ca26. Relevant owning-package normal/race runs, eight selected tests with 100 race repetitions each, real two-CN SQL contracts, and incremental static checks passed. The earlier failed Stop-fallback fixture expectation was corrected and superseded by the passing full compile normal/race and stress runs. Unchanged suites were not rerun merely for this review.

Performance evidence for this revision versus the previous PR revision (812aeaa) contains 93,184 validated SQL statements. Eight warm cells cover reuse on/off, SUM/early stop, and 1/8 clients; median QPS changes range from -1.59% to +7.63%. Some small-sample P99 medians rose about 7%. Larger ABBA tail comparisons cover only reuse-enabled SUM with 8 clients and reuse-disabled early stop with 8 clients; those did not show a stable regression. The other six cells retain smaller warm diagnostics. This is not a production-tail or all-workload guarantee, nor a fresh comparison against latest main.

Category Added Deleted Net
Implementation 671 641 +30
Tests 2,175 1,382 +793
Documentation 0 0 0

The implementation increase earns concrete failure-preservation and bounded-cleanup benefits. Test growth was reviewed by behavior and boundary rather than treated as exempt from complexity review.

At submission, the head is unchanged and CI has no failed checks; Ubuntu UT, Linux/arm64 SCA, PROXY BVT, and COMPOSE PESSIMISTIC BVT are still running. Coverage has passed. Latest main contains one additional unary-function refactor and GitHub reports the PR mergeable. The original historical chaos/DROP interleaving and physical CN-kill behavior are not claimed as reproduced by these tests.

This branch was previously deployed

1 inactive deployment
ci — a3ab1f97 Deployed Oct 5, 2026 by XuPeng-SH
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/refactor Code refactor size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants