Skip to content

[main] fix(pipeline): wake receivers from terminal edge state - #26250

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
aptend:fix/main-pipeline-terminal-wakeup
Jul 27, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
aptend:fix/main-pipeline-terminal-wakeup

Conversation

@aptend

@aptend aptend commented Jul 27, 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:

Related to #26125 and #26202.

Main forward-port of #26228, which carries the same logical fix for 4.2-dev.

What this PR does / why we need it:

A fatal PipelineEdge terminal is recorded and closes Done() before all required terminal signals are enqueued into Ch2. When Ch2 is backpressured, the typed terminal signal can remain partially or completely undelivered. PipelineSignalReceiver previously waited only on its user context and Ch2, so it could remain blocked after the edge was already terminal. That leaves Merge, RemoteRun, and ultimately Compile.runOnce waiting indefinitely.

This change:

  • listens to each edge Done() channel in both the optimized 1–8 input selects and the reflect.Select path;
  • drains buffered Ch2 signals before synthesizing a missing terminal from the durable edge state;
  • synchronizes and rechecks Ch2 to preserve ordering across the fatal-state/enqueue race;
  • makes fatal terminal enqueue non-blocking while holding the terminal-state mutex, avoiding a control-path wait cycle behind the data channel;
  • adds regressions for buffered ordering, undelivered fatal terminals, shared edges, connector fallback cleanup, and reflect-select removal/reindexing across the 9-to-8 input transition.

Normal End delivery and the legacy nil-batch compatibility path remain unchanged. The forward-port applies cleanly and is patch-equivalent to #26228.

Validation

  • make thirdparties && make cgo
  • go build ./pkg/vm/process ./pkg/sql/colexec/connector ./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch
  • go vet ./pkg/vm/process ./pkg/sql/colexec/connector ./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch
  • focused new regressions with -race -count=20
  • go test -race -count=1 -timeout=600s ./pkg/vm/process ./pkg/sql/colexec/connector
  • go test -count=1 -timeout=600s ./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch
  • git diff --check

@aptend
aptend requested review from XuPeng-SH and aunjgr as code owners July 27, 2026 11:00
@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 →

@XuPeng-SH
XuPeng-SH merged commit f022e5f into matrixorigin:main Jul 27, 2026
23 of 24 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 27, 2026
mergify Bot pushed a commit that referenced this pull request Jul 28, 2026
When normal End delivery fails on a shared `PipelineEdge` that already records a real terminal error, Connector or Dispatch cleanup currently aborts its spool with `ErrPipelineEndSignalDeliveryFailed`. Buffered spool signals can then surface that synthetic cleanup error before the durable execution error.

This change resolves the spool abort cause from receiver edges first and only falls back to `ErrPipelineEndSignalDeliveryFailed` when no more specific terminal error exists. It keeps the terminal wakeup and bounded cleanup behavior from #26250 unchanged.

Validation:

- focused Connector regression with `-race -count=20`
- `go test -race -count=1 ./pkg/vm/process ./pkg/sql/colexec/connector ./pkg/sql/colexec/dispatch`
- `go test -count=1 ./pkg/vm/pipeline`
- `go build` and `go vet` for all changed packages plus `pkg/vm/pipeline`

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

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#26125 and matrixorigin#26202.

Main forward-port of matrixorigin#26228, which carries the same logical fix for
`4.2-dev`.

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

A fatal `PipelineEdge` terminal is recorded and closes `Done()` before
all required terminal signals are enqueued into `Ch2`. When `Ch2` is
backpressured, the typed terminal signal can remain partially or
completely undelivered. `PipelineSignalReceiver` previously waited only
on its user context and `Ch2`, so it could remain blocked after the edge
was already terminal. That leaves `Merge`, `RemoteRun`, and ultimately
`Compile.runOnce` waiting indefinitely.

This change:

- listens to each edge `Done()` channel in both the optimized 1–8 input
selects and the `reflect.Select` path;
- drains buffered `Ch2` signals before synthesizing a missing terminal
from the durable edge state;
- synchronizes and rechecks `Ch2` to preserve ordering across the
fatal-state/enqueue race;
- makes fatal terminal enqueue non-blocking while holding the
terminal-state mutex, avoiding a control-path wait cycle behind the data
channel;
- adds regressions for buffered ordering, undelivered fatal terminals,
shared edges, connector fallback cleanup, and reflect-select
removal/reindexing across the 9-to-8 input transition.

Normal `End` delivery and the legacy nil-batch compatibility path remain
unchanged. The forward-port applies cleanly and is patch-equivalent to
matrixorigin#26228.

## Validation

- `make thirdparties && make cgo`
- `go build ./pkg/vm/process ./pkg/sql/colexec/connector
./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch`
- `go vet ./pkg/vm/process ./pkg/sql/colexec/connector
./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch`
- focused new regressions with `-race -count=20`
- `go test -race -count=1 -timeout=600s ./pkg/vm/process
./pkg/sql/colexec/connector`
- `go test -count=1 -timeout=600s ./pkg/sql/colexec/merge
./pkg/sql/colexec/dispatch`
- `git diff --check`

---------

Co-authored-by: XuPeng-SH <[email protected]>
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
…in#26324)

When normal End delivery fails on a shared `PipelineEdge` that already records a real terminal error, Connector or Dispatch cleanup currently aborts its spool with `ErrPipelineEndSignalDeliveryFailed`. Buffered spool signals can then surface that synthetic cleanup error before the durable execution error.

This change resolves the spool abort cause from receiver edges first and only falls back to `ErrPipelineEndSignalDeliveryFailed` when no more specific terminal error exists. It keeps the terminal wakeup and bounded cleanup behavior from matrixorigin#26250 unchanged.

Validation:

- focused Connector regression with `-race -count=20`
- `go test -race -count=1 ./pkg/vm/process ./pkg/sql/colexec/connector ./pkg/sql/colexec/dispatch`
- `go test -count=1 ./pkg/vm/pipeline`
- `go build` and `go vet` for all changed packages plus `pkg/vm/pipeline`

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

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#26125 and matrixorigin#26202.

Main forward-port of matrixorigin#26228, which carries the same logical fix for
`4.2-dev`.

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

A fatal `PipelineEdge` terminal is recorded and closes `Done()` before
all required terminal signals are enqueued into `Ch2`. When `Ch2` is
backpressured, the typed terminal signal can remain partially or
completely undelivered. `PipelineSignalReceiver` previously waited only
on its user context and `Ch2`, so it could remain blocked after the edge
was already terminal. That leaves `Merge`, `RemoteRun`, and ultimately
`Compile.runOnce` waiting indefinitely.

This change:

- listens to each edge `Done()` channel in both the optimized 1–8 input
selects and the `reflect.Select` path;
- drains buffered `Ch2` signals before synthesizing a missing terminal
from the durable edge state;
- synchronizes and rechecks `Ch2` to preserve ordering across the
fatal-state/enqueue race;
- makes fatal terminal enqueue non-blocking while holding the
terminal-state mutex, avoiding a control-path wait cycle behind the data
channel;
- adds regressions for buffered ordering, undelivered fatal terminals,
shared edges, connector fallback cleanup, and reflect-select
removal/reindexing across the 9-to-8 input transition.

Normal `End` delivery and the legacy nil-batch compatibility path remain
unchanged. The forward-port applies cleanly and is patch-equivalent to
matrixorigin#26228.

## Validation

- `make thirdparties && make cgo`
- `go build ./pkg/vm/process ./pkg/sql/colexec/connector
./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch`
- `go vet ./pkg/vm/process ./pkg/sql/colexec/connector
./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch`
- focused new regressions with `-race -count=20`
- `go test -race -count=1 -timeout=600s ./pkg/vm/process
./pkg/sql/colexec/connector`
- `go test -count=1 -timeout=600s ./pkg/sql/colexec/merge
./pkg/sql/colexec/dispatch`
- `git diff --check`

---------

Co-authored-by: XuPeng-SH <[email protected]>
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
…in#26324)

When normal End delivery fails on a shared `PipelineEdge` that already records a real terminal error, Connector or Dispatch cleanup currently aborts its spool with `ErrPipelineEndSignalDeliveryFailed`. Buffered spool signals can then surface that synthetic cleanup error before the durable execution error.

This change resolves the spool abort cause from receiver edges first and only falls back to `ErrPipelineEndSignalDeliveryFailed` when no more specific terminal error exists. It keeps the terminal wakeup and bounded cleanup behavior from matrixorigin#26250 unchanged.

Validation:

- focused Connector regression with `-race -count=20`
- `go test -race -count=1 ./pkg/vm/process ./pkg/sql/colexec/connector ./pkg/sql/colexec/dispatch`
- `go test -count=1 ./pkg/vm/pipeline`
- `go build` and `go vet` for all changed packages plus `pkg/vm/pipeline`

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

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#26125 and matrixorigin#26202.

Main forward-port of matrixorigin#26228, which carries the same logical fix for
`4.2-dev`.

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

A fatal `PipelineEdge` terminal is recorded and closes `Done()` before
all required terminal signals are enqueued into `Ch2`. When `Ch2` is
backpressured, the typed terminal signal can remain partially or
completely undelivered. `PipelineSignalReceiver` previously waited only
on its user context and `Ch2`, so it could remain blocked after the edge
was already terminal. That leaves `Merge`, `RemoteRun`, and ultimately
`Compile.runOnce` waiting indefinitely.

This change:

- listens to each edge `Done()` channel in both the optimized 1–8 input
selects and the `reflect.Select` path;
- drains buffered `Ch2` signals before synthesizing a missing terminal
from the durable edge state;
- synchronizes and rechecks `Ch2` to preserve ordering across the
fatal-state/enqueue race;
- makes fatal terminal enqueue non-blocking while holding the
terminal-state mutex, avoiding a control-path wait cycle behind the data
channel;
- adds regressions for buffered ordering, undelivered fatal terminals,
shared edges, connector fallback cleanup, and reflect-select
removal/reindexing across the 9-to-8 input transition.

Normal `End` delivery and the legacy nil-batch compatibility path remain
unchanged. The forward-port applies cleanly and is patch-equivalent to
matrixorigin#26228.

## Validation

- `make thirdparties && make cgo`
- `go build ./pkg/vm/process ./pkg/sql/colexec/connector
./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch`
- `go vet ./pkg/vm/process ./pkg/sql/colexec/connector
./pkg/sql/colexec/merge ./pkg/sql/colexec/dispatch`
- focused new regressions with `-race -count=20`
- `go test -race -count=1 -timeout=600s ./pkg/vm/process
./pkg/sql/colexec/connector`
- `go test -count=1 -timeout=600s ./pkg/sql/colexec/merge
./pkg/sql/colexec/dispatch`
- `git diff --check`

---------

Co-authored-by: XuPeng-SH <[email protected]>
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
…in#26324)

When normal End delivery fails on a shared `PipelineEdge` that already records a real terminal error, Connector or Dispatch cleanup currently aborts its spool with `ErrPipelineEndSignalDeliveryFailed`. Buffered spool signals can then surface that synthetic cleanup error before the durable execution error.

This change resolves the spool abort cause from receiver edges first and only falls back to `ErrPipelineEndSignalDeliveryFailed` when no more specific terminal error exists. It keeps the terminal wakeup and bounded cleanup behavior from matrixorigin#26250 unchanged.

Validation:

- focused Connector regression with `-race -count=20`
- `go test -race -count=1 ./pkg/vm/process ./pkg/sql/colexec/connector ./pkg/sql/colexec/dispatch`
- `go test -count=1 ./pkg/vm/pipeline`
- `go build` and `go vet` for all changed packages plus `pkg/vm/pipeline`

Approved by: @XuPeng-SH

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants