Skip to content

[4.2-dev] fix(pipeline): make terminal completion durable - #27991

Merged
mergify[bot] merged 3 commits into
matrixorigin:4.2-devfrom
aptend:fix/27987-pipeline-end-4.2-dev
Sep 2, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:4.2-devfrom
aptend:fix/27987-pipeline-end-4.2-dev

Conversation

@aptend

@aptend aptend commented Sep 2, 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 #27987

What this PR does / why we need it:

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

…ors (matrixorigin#26990)

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

Fixes matrixorigin#26743
Fixes matrixorigin#26745

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>
(cherry picked from commit fe62a8f)
@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.

This backport is incomplete on the remote-notify cancellation path.

sendNotifyMessageWithFactoryAndWait.closeWithError still calls suppressRemoteNotifyCancelError, which only suppresses ErrQueryInterrupted. On 4.2 head, a notifier returning raw context.Canceled after the pipeline has been canceled (1) loses an already-recorded substantive cancel cause, and (2) reports ordinary internal cancellation as a terminal error. I reproduced both cases on 22e5aa27e9; replacing that call with normalizeScopeRunError(err, s.Proc.Ctx, scopeRunQueryContext(s.Proc)) makes the full regression matrix pass 100 times.

Please backport the remote-notify half of main #27537 (including its regression matrix), or land it as an explicit prerequisite before merging this PR. This is needed for the PR's stated root-error preservation contract and avoids publishing EventError for normal remote early-stop cleanup.

Validated separately: durable End ordering, multi-sender/full-channel delivery, spool cleanup ownership, and focused race tests are otherwise 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.

Deep re-review of exact head 88f034fa3fb0b7acf21a92747b7d21f2721b0536 against 4.2-dev base b2a873419200b3685fe4dd89401857440a0e145c.

The previous remote-notify blocker is closed. closeWithError now uses the same normalizeScopeRunError contract as local/remote scope aggregation, and the added matrix distinguishes raw pipeline cancellation, query cancellation, active-pipeline cancellation, query interruption, and a substantive cancellation cause.

I rechecked the complete sender/receiver/cleanup closure and counterexamples:

  • End is recorded durably even when Ch2 is full; receivers drain already-buffered data before synthesizing a missing End.
  • Multi-sender completion is bounded by NilBatchCnt/endRecorded; fatal first-wins state accounts for remaining senders without waiting behind data.
  • Reset/reuse drains stale direct batches and spool references before replacing terminal state.
  • Query deadlines preserve context.DeadlineExceeded; joined substantive/deadline leaves are not hidden by sibling cancellation.
  • Cleanup notification, Done/Abort publication, and receiver termination have independent bounded/non-blocking release paths.
  • No new goroutine, retry accumulation, unbounded queue, per-row logging, double cleanup, or terminal wait cycle is introduced.

Exact-head Ubuntu UT, SCA, build, coverage, PROXY/PESSIMISTIC BVT, Iceberg and MongoDB E2E are terminal green; git diff --check passes and the exact base merge-tree is clean. No blocking correctness, liveness, resource, performance, compatibility, or unhappy-path issue found.

@mergify mergify Bot added the queued label Sep 2, 2026
@mergify

mergify Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-02 14:23 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-02 14:24 UTC · at dad3554830240904588d7c0a812f42142c791a9a · squash

This pull request spent 22 seconds in the queue, including 3 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • 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)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

@mergify
mergify Bot merged commit dad3554 into matrixorigin:4.2-dev Sep 2, 2026
28 of 29 checks passed
@mergify mergify Bot removed the queued label Sep 2, 2026
XuPeng-SH added a commit that referenced this pull request Nov 14, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Refs #27991, #31064, #31089, #28473 and #30738.

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

The dated 4.2.1 hotfix tags fork from `v4.2.1`; the `v4.2.1-hotfix`
branch at `115c227239` does not contain all their fixes. Consolidate the
missing changes so the branch preserves pipeline
completion/cancellation, correct catalog index types, and the later SQL,
vector and backup/restore fixes.

| Source tag | Changes | Source commits |
| --- | --- | --- |
| `20260902` | Durable pipeline End completion and preservation of
primary query errors | `07a7e871ec` |
| `20260909` | Correct logical-ID index primary-column type |
`2cb5379d78` |
| `20261025` | Release materialized CTE batches and readers |
`9ebefa5bc1` |
| `20261026` | Resolve secondary indexes in subscriptions | `47e644f2d7`
|
| `20261029` | Skip empty predicate traversals; reuse window aggregate
frames; preserve vector ownership on clone/transaction errors |
`7ce664f08a`, `f6a27941d7`, `3391c6844e` |
| `20261030` | Preserve GC retention evidence and table-ID history
through physical backup/restore | `e0e2308d07` |
| `20261104` | Release accounted window buffers on prepared Reset;
preserve vector Area when admission fails | `d8286add27`, `15b1983f04` |

All ten cherry-picks are conflict-free and retain their source patch IDs
and `-x` provenance. The ETL and multi-CN IVF fixes are already present
in the base; `9572bd3311` and `87866e6d28` require no duplicate changes.
The final tree equals the `20261104` tag plus the `20260902` pipeline
and `20260909` catalog fixes, verified by a combined stable patch-ID
comparison.

Catalog migration SQL, order, versions and offsets are unchanged. The
pending catalog-upgrade/lineage dependency fix is separate from this
consolidation.

### Validation

- Linux/amd64, Go 1.26.4, CGO enabled; branch-matched `make
thirdparties`, `make cgo`, and release `make build`: PASS.
- Full normal suites for all 21 changed component packages, plus the two
new real authenticated SQL witnesses in `pkg/tests/issues`: PASS.
- Full race suites for 15 affected lifecycle packages and the two SQL
witnesses: PASS.
- Adaptive race stress for 56 individual changed lifecycle regressions:
5,237 successful repetitions; each exact test selected separately, using
terminal JSON timing and a 30-second per-test budget capped at 100
repetitions: PASS.
- Full `go vet -mod=readonly -p=4 ./...`: PASS.
- Repository-pinned golangci-lint 2.6.2 with unchanged `.golangci.yml`,
tests enabled, full package/reverse-dependency coverage: PASS against
both `origin/v4.2.1-hotfix` and freshly fetched `origin/main` using `run
--new-from-rev=<base> ./...`.
- `molint check -mod=readonly -p=4 ./...`: no new diagnostics. Three
`checkrecover` findings in unchanged CDC, lockservice and planner code
reproduce identically on clean base `115c227239`.
- Official `mo-tester` comparison mode on a dedicated service: large
LIMIT, unbounded windows and subscription secondary indexes, **58/58 SQL
checks PASS**. The separate 8 MiB HashJoin fixture is included for QA;
local admission coverage is in the vector/HashJoin normal and race
suites.
- `git diff --check`: PASS.

The GC metadata extension preserves the original block-zero
representation and reads legacy one-block metadata. This PR does not
repair previously incomplete backup archives. Deployment follows the
existing full-shutdown, uniform-version upgrade contract.

---------

Co-authored-by: GreatRiver <[email protected]>
Co-authored-by: gouhongshen <[email protected]>
Co-authored-by: Cao Kai <[email protected]>
Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: GreatRiver <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: 和光同尘 <[email protected]>

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.

3 participants