Skip to content

fix(pipeline): make terminal completion durable and preserve root errors - #26990

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aptend:fix/pipeline-terminal-errors-26743-26745
Aug 12, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aptend:fix/pipeline-terminal-errors-26743-26745

Conversation

@aptend

@aptend aptend commented Aug 12, 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:

Fixes #26743
Fixes #26745

What this PR does / why we need it:

This fixes two execution-mechanism failures, independently of query-plan quality:

  • Records normal pipeline completion as durable edge state, so a full data channel cannot turn End into pipeline end signal delivery failed. Receivers drain buffered data before observing the recorded terminal state.
  • Preserves substantive operator failures across sibling-pipeline cancellation. Cancellation is suppressed or replaced only when every error-tree leaf is attributable to the same canceled context; independent deadlines and joined substantive errors survive scope aggregation and remote cleanup.
  • Keeps query-owned timeouts classified as context deadline exceeded, while allowing the internal-executor cause to be attached by the owning caller.

Q4 may still exceed the hash-build memory budget with its current plan; after this change the client receives that actual resource error instead of context canceled.

Record normal pipeline completion durably even when data fills the signal channel, and keep substantive execution failures from being replaced by sibling cancellation fallout.\n\nFixes matrixorigin#26743\nFixes matrixorigin#26745
@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 →

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 120107d against merge base 9a7c98b.

[P1] Preserve an independent deadline when it is joined with cancellation fallout.

If an operator returns errors.Join(context.DeadlineExceeded, context.Canceled) while the pipeline is normally canceled, isScopeCancellationError accepts every leaf, errors.Is(err, pipelineCtx.Err()) succeeds through the context.Canceled sibling, and the pipeline cause replaces the whole join. With an active query context, lines 624-628 then normalize the result to nil. Scope.Run therefore reports success even though the independent operator deadline should remain terminal. The direct DeadlineExceeded case in TestScopeRunPreservesCancellationCause does not exercise this joined form.

Please classify the cancellation leaves by their causal source (or otherwise retain any independent deadline leaf) and add the joined DeadlineExceeded + Canceled counterexample.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 120107d against merge base 9a7c98b.

[P1] Preserve an independent deadline inside a joined cancellation error.

isScopeCancellationError treats errors.Join(context.DeadlineExceeded, context.Canceled) as wholly cancellation-shaped. If the pipeline was normally canceled, errors.Is(err, pipelineCtx.Err()) succeeds through the context.Canceled leaf; lines 624-628 then replace the complete join with the pipeline cancellation cause and suppress it because the query context is still active. Scope.Run consequently returns success even though an independent operator deadline occurred.

A minimal counterexample on this head calls normalizeScopeRunError(errors.Join(context.DeadlineExceeded, context.Canceled), normallyCanceledPipelineCtx, activeQueryCtx): expected an error matching context.DeadlineExceeded, got nil.

Please classify joined leaves by causal source or retain independent deadline leaves, and add this exact regression. The durable End/Done state machine, spool cleanup ordering, query-owned deadline classification, and first substantive root-error propagation otherwise look sound.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 3c62ade against merge base 9a7c98b.

No blocking findings.

The latest commit closes my previous P1: joined errors are now classified leaf by leaf, so errors.Join(context.DeadlineExceeded, context.Canceled) cannot be attributed wholesale to normal pipeline cancellation. The new Scope.Run and remote-cancellation regressions exercise that exact counterexample.

Lifecycle review also checks out:

  • End is recorded durably without waiting for Ch2 capacity; Done wakes the receiver, which drains queued data/signals before synthesizing a missing End.
  • Shared-sender counts and fatal first-wins state remain coherent across full channels; Error/Abort causes stay observable.
  • Connector/Dispatch defer normal spool reclamation until the paired Merge has quiesced, while failure paths abort immediately; reuse drains stale signal-owned resources before resetting terminal state.
  • Scope aggregation preserves substantive/root errors, independent deadlines, query-owned deadline classification, and only suppresses cancellation leaves attributable to the same canceled context.

Validated on this exact head:

  • go build and go vet: pkg/vm/process, pkg/sql/compile, pkg/sql/colexec/connector, pkg/sql/colexec/dispatch, pkg/vm/pipeline
  • go test -count=1 for all five packages
  • go test -race for the terminal, connector/dispatch cleanup, scope error-normalization, and remote cancellation regressions

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the durable terminal-state delivery and cancellation/error normalization paths. The shared-sender, buffered-data, and mixed cancellation/error cases are covered; the patch preserves meaningful execution errors and query-deadline classification.

@mergify mergify Bot added the queued label Aug 12, 2026
@mergify

mergify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-12 10:22 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-12 10:46 UTC · at 57725f41dc25c467b02632d6b56a3aca90d42746

This pull request spent 23 minutes 52 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #26990 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit fe62a8f into matrixorigin:main Aug 12, 2026
25 of 26 checks passed
@mergify mergify Bot added dequeued and removed queued labels Aug 12, 2026
mergify Bot pushed a commit that referenced this pull request Sep 2, 2026
Backports #26990 to 4.2-dev.

A normal pipeline End is now recorded as durable edge state even when the bounded data channel is full. The receiver drains buffered batches before observing the recorded End, preventing a slow full-table-scan consumer from turning graceful completion into pipeline end signal delivery failed.

The backport also preserves substantive execution errors across sibling-pipeline cancellation and keeps query deadline classification intact. Existing 4.2-dev cancellation helpers were retained while resolving the cherry-pick conflict.

Validation:

- Focused regression tests across process, connector, dispatch, and compile
- Full owning-package tests
- Focused race stress for concurrent terminal publication, count 100
- Full owning-package race tests
- go build and go vet for all affected packages

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…ors (matrixorigin#26990)

## 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#26743
Fixes matrixorigin#26745

## What this PR does / why we need it:

This fixes two execution-mechanism failures, independently of query-plan
quality:

- Records normal pipeline completion as durable edge state, so a full
data channel cannot turn `End` into `pipeline end signal delivery
failed`. Receivers drain buffered data before observing the recorded
terminal state.
- Preserves substantive operator failures across sibling-pipeline
cancellation. Cancellation is suppressed or replaced only when every
error-tree leaf is attributable to the same canceled context;
independent deadlines and joined substantive errors survive scope
aggregation and remote cleanup.
- Keeps query-owned timeouts classified as `context deadline exceeded`,
while allowing the internal-executor cause to be attached by the owning
caller.

Q4 may still exceed the hash-build memory budget with its current plan;
after this change the client receives that actual resource error instead
of `context canceled`.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…ors (matrixorigin#26990)

## 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#26743
Fixes matrixorigin#26745

## What this PR does / why we need it:

This fixes two execution-mechanism failures, independently of query-plan
quality:

- Records normal pipeline completion as durable edge state, so a full
data channel cannot turn `End` into `pipeline end signal delivery
failed`. Receivers drain buffered data before observing the recorded
terminal state.
- Preserves substantive operator failures across sibling-pipeline
cancellation. Cancellation is suppressed or replaced only when every
error-tree leaf is attributable to the same canceled context;
independent deadlines and joined substantive errors survive scope
aggregation and remote cleanup.
- Keeps query-owned timeouts classified as `context deadline exceeded`,
while allowing the internal-executor cause to be attached by the owning
caller.

Q4 may still exceed the hash-build memory budget with its current plan;
after this change the client receives that actual resource error instead
of `context canceled`.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…ors (matrixorigin#26990)

## 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#26743
Fixes matrixorigin#26745

## What this PR does / why we need it:

This fixes two execution-mechanism failures, independently of query-plan
quality:

- Records normal pipeline completion as durable edge state, so a full
data channel cannot turn `End` into `pipeline end signal delivery
failed`. Receivers drain buffered data before observing the recorded
terminal state.
- Preserves substantive operator failures across sibling-pipeline
cancellation. Cancellation is suppressed or replaced only when every
error-tree leaf is attributable to the same canceled context;
independent deadlines and joined substantive errors survive scope
aggregation and remote cleanup.
- Keeps query-owned timeouts classified as `context deadline exceeded`,
while allowing the internal-executor cause to be attached by the owning
caller.

Q4 may still exceed the hash-build memory budget with its current plan;
after this change the client receives that actual resource error instead
of `context canceled`.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
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 size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TPC-DS 1TB Q4 returns context canceled instead of the HashBuild failure [Bug]: TPC-DS 1TB Q74 fails with pipeline end signal delivery failed

4 participants