Skip to content

[4.2-dev] fix(pipeline): wake receivers from terminal edge state - #26228

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
aptend:fix/26202-pipeline-terminal-wakeup
Jul 27, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
aptend:fix/26202-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 #26202 and #26125.

This PR targets 4.2-dev for #26202. The same logical change needs to be forward-ported to main for the #26125 reproduction.

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.

Validation

  • 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/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 07:15
@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 →

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

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

Deep-reviewed the terminal-edge wakeup protocol on 9c7d4b9. Done wakeups preserve queued Ch2 ordering, synchronize with in-flight fatal senders, and keep shared-edge and reflect-select bookkeeping correct. Focused race tests (20x), affected/dependent package tests, build, and vet all pass locally. The remaining Coverage check failure is an artifact-collection issue (missing compose BVT profile); the latest SCA, UT, and BVT checks pass.

@aptend aptend closed this Jul 27, 2026
@aptend aptend reopened this Jul 27, 2026
@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 →

@aptend aptend changed the title fix(pipeline): wake receivers from terminal edge state [4.2-dev] fix(pipeline): wake receivers from terminal edge state Jul 27, 2026
@XuPeng-SH
XuPeng-SH merged commit 46dfc97 into matrixorigin:4.2-dev Jul 27, 2026
123 of 135 checks passed
XuPeng-SH added a commit that referenced this pull request Jul 27, 2026
## 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 #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`

---------

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
…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
…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
…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>

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