Skip to content

fix(pipeline): preserve JoinMap cancellation causes - #27648

Merged
XuPeng-SH merged 5 commits into
mainfrom
codex/issue-27646-root-error
Aug 26, 2026
Merged

XuPeng-SH merged 5 commits into
mainfrom
codex/issue-27646-root-error

Conversation

@XuPeng-SH

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 #27646

What this PR does / why we need it:

A multi-target INSERT can raise a real target-side error (for example, an invalid ENUM value) while canceling a sibling HashBuild pipeline. The JoinMap dependency used to convert that sibling context.Canceled into an ordinary internal moerr, so scope arbitration could no longer recognize it as cancellation fallout and could return internal error: context canceled instead of the causal execution error.

This PR:

  • preserves wrapped and joined cancellation/deadline identity through JoinMap failure publication;
  • keeps substantive MatrixOne errors (OOM, storage errors, and similar failures) authoritative when mixed with cancellation;
  • propagates the preserved identity from both JoinMap receive paths so existing scope arbitration can select the causal error;
  • keeps JoinMapResult.Err() and stable moerr code/detail behavior compatible;
  • adds message-boundary, hash-join operator, cleanup/memory, and scope-arbitration regression tests.

Performance

The successful JoinMap path is unchanged. Cancellation-tree classification runs once only when a HashBuild publishes a terminal failure. No row/batch hot path, lock, goroutine, wait dependency, or unbounded state is added.

Unhappy paths and risk

  • Pure cancellation, wrapped cancellation, deadline, and joined cancellation/deadline retain errors.Is identity.
  • Cancellation joined with OOM or a generic execution failure remains a substantive failure and is not downgraded to cleanup fallout.
  • A failed build stops before consuming or emitting probe rows and cleanup returns memory usage to zero.
  • The broadcast terminal-state and generation/ownership protocols are unchanged.
  • The existing multi-target INSERT BVT remains the end-to-end regression; this change fixes the lower-level error transport that made it nondeterministic.

Validation

  • go build -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin ./pkg/sql/compile
  • go vet -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin ./pkg/sql/compile
  • go test -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin ./pkg/sql/compile
  • go test -mod=readonly -race ./pkg/vm/message ./pkg/sql/colexec/hashjoin ./pkg/sql/compile
  • New cancellation/error-arbitration tests under -race -count=100

Keep context cancellation identity through JoinMap dependency publication so scope arbitration can return the causal execution failure instead of sibling cleanup fallout. Preserve substantive MatrixOne errors and add message, operator, and scope regression coverage.\n\nFixes #27646
@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 →

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the full diff and the producer → JoinMap broadcast → all consumer operators → scope arbitration closure. Cancellation/deadline identity is preserved only for all-cancellation error trees; mixed substantive failures remain authoritative. No new ownership, wait-for, generation, or unbounded-growth edge was introduced. Fresh local validation passed: gofmt/diff-check, build, vet, full tests and full race tests for pkg/vm/message, pkg/sql/colexec/hashjoin, and pkg/sql/compile; all 7 changed/new focused tests also passed under -race -count=100. No blocking findings.

@XuPeng-SH
XuPeng-SH merged commit 2339b3b into main Aug 26, 2026
8 of 11 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-27646-root-error branch August 26, 2026 13:43
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 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:

Fixes matrixorigin#27646

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

A multi-target INSERT can raise a real target-side error (for example,
an invalid ENUM value) while canceling a sibling HashBuild pipeline. The
JoinMap dependency used to convert that sibling `context.Canceled` into
an ordinary internal `moerr`, so scope arbitration could no longer
recognize it as cancellation fallout and could return `internal error:
context canceled` instead of the causal execution error.

This PR:

- preserves wrapped and joined cancellation/deadline identity through
JoinMap failure publication;
- keeps substantive MatrixOne errors (OOM, storage errors, and similar
failures) authoritative when mixed with cancellation;
- propagates the preserved identity from both JoinMap receive paths so
existing scope arbitration can select the causal error;
- keeps `JoinMapResult.Err()` and stable `moerr` code/detail behavior
compatible;
- adds message-boundary, hash-join operator, cleanup/memory, and
scope-arbitration regression tests.

### Performance

The successful JoinMap path is unchanged. Cancellation-tree
classification runs once only when a HashBuild publishes a terminal
failure. No row/batch hot path, lock, goroutine, wait dependency, or
unbounded state is added.

### Unhappy paths and risk

- Pure cancellation, wrapped cancellation, deadline, and joined
cancellation/deadline retain `errors.Is` identity.
- Cancellation joined with OOM or a generic execution failure remains a
substantive failure and is not downgraded to cleanup fallout.
- A failed build stops before consuming or emitting probe rows and
cleanup returns memory usage to zero.
- The broadcast terminal-state and generation/ownership protocols are
unchanged.
- The existing multi-target INSERT BVT remains the end-to-end
regression; this change fixes the lower-level error transport that made
it nondeterministic.

### Validation

- `go build -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go vet -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go test -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go test -mod=readonly -race ./pkg/vm/message
./pkg/sql/colexec/hashjoin ./pkg/sql/compile`
- New cancellation/error-arbitration tests under `-race -count=100`
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 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:

Fixes matrixorigin#27646

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

A multi-target INSERT can raise a real target-side error (for example,
an invalid ENUM value) while canceling a sibling HashBuild pipeline. The
JoinMap dependency used to convert that sibling `context.Canceled` into
an ordinary internal `moerr`, so scope arbitration could no longer
recognize it as cancellation fallout and could return `internal error:
context canceled` instead of the causal execution error.

This PR:

- preserves wrapped and joined cancellation/deadline identity through
JoinMap failure publication;
- keeps substantive MatrixOne errors (OOM, storage errors, and similar
failures) authoritative when mixed with cancellation;
- propagates the preserved identity from both JoinMap receive paths so
existing scope arbitration can select the causal error;
- keeps `JoinMapResult.Err()` and stable `moerr` code/detail behavior
compatible;
- adds message-boundary, hash-join operator, cleanup/memory, and
scope-arbitration regression tests.

### Performance

The successful JoinMap path is unchanged. Cancellation-tree
classification runs once only when a HashBuild publishes a terminal
failure. No row/batch hot path, lock, goroutine, wait dependency, or
unbounded state is added.

### Unhappy paths and risk

- Pure cancellation, wrapped cancellation, deadline, and joined
cancellation/deadline retain `errors.Is` identity.
- Cancellation joined with OOM or a generic execution failure remains a
substantive failure and is not downgraded to cleanup fallout.
- A failed build stops before consuming or emitting probe rows and
cleanup returns memory usage to zero.
- The broadcast terminal-state and generation/ownership protocols are
unchanged.
- The existing multi-target INSERT BVT remains the end-to-end
regression; this change fixes the lower-level error transport that made
it nondeterministic.

### Validation

- `go build -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go vet -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go test -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go test -mod=readonly -race ./pkg/vm/message
./pkg/sql/colexec/hashjoin ./pkg/sql/compile`
- New cancellation/error-arbitration tests under `-race -count=100`
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 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:

Fixes matrixorigin#27646

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

A multi-target INSERT can raise a real target-side error (for example,
an invalid ENUM value) while canceling a sibling HashBuild pipeline. The
JoinMap dependency used to convert that sibling `context.Canceled` into
an ordinary internal `moerr`, so scope arbitration could no longer
recognize it as cancellation fallout and could return `internal error:
context canceled` instead of the causal execution error.

This PR:

- preserves wrapped and joined cancellation/deadline identity through
JoinMap failure publication;
- keeps substantive MatrixOne errors (OOM, storage errors, and similar
failures) authoritative when mixed with cancellation;
- propagates the preserved identity from both JoinMap receive paths so
existing scope arbitration can select the causal error;
- keeps `JoinMapResult.Err()` and stable `moerr` code/detail behavior
compatible;
- adds message-boundary, hash-join operator, cleanup/memory, and
scope-arbitration regression tests.

### Performance

The successful JoinMap path is unchanged. Cancellation-tree
classification runs once only when a HashBuild publishes a terminal
failure. No row/batch hot path, lock, goroutine, wait dependency, or
unbounded state is added.

### Unhappy paths and risk

- Pure cancellation, wrapped cancellation, deadline, and joined
cancellation/deadline retain `errors.Is` identity.
- Cancellation joined with OOM or a generic execution failure remains a
substantive failure and is not downgraded to cleanup fallout.
- A failed build stops before consuming or emitting probe rows and
cleanup returns memory usage to zero.
- The broadcast terminal-state and generation/ownership protocols are
unchanged.
- The existing multi-target INSERT BVT remains the end-to-end
regression; this change fixes the lower-level error transport that made
it nondeterministic.

### Validation

- `go build -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go vet -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go test -mod=readonly ./pkg/vm/message ./pkg/sql/colexec/hashjoin
./pkg/sql/compile`
- `go test -mod=readonly -race ./pkg/vm/message
./pkg/sql/colexec/hashjoin ./pkg/sql/compile`
- New cancellation/error-arbitration tests under `-race -count=100`

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.

fix: preserve root execution errors when JoinMapBuildError wraps cancellation

3 participants