Skip to content

fix(plan): safely classify DML planner errors - #26731

Merged
XuPeng-SH merged 2 commits into
mainfrom
codex/issue26730-systematic-fix
Aug 5, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
codex/issue26730-systematic-fix

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Aug 5, 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 #26730

What this PR does / why we need it:

Planner fallback routing accepted the general error interface, but INSERT,
LOAD, and DELETE assumed every binder error was a *moerr.Error. Storage
cancellation, deadlines, and other ordinary Go errors could therefore panic
while checking for ErrUnsupportedDML.

This change:

  • uses the existing safe moerr.IsMoErrCode predicate at every affected DML
    fallback boundary;
  • preserves non-MO errors and wrapped cancellation errors without converting
    or swallowing them;
  • keeps the existing legacy fallback behavior for genuine
    ErrUnsupportedDML;
  • adds a systematic matrix covering INSERT, LOAD, DELETE, UPDATE, and REPLACE
    against cancellation, deadline, plain, and wrapped errors, plus positive
    fallback controls.

Validation:

  • GOWORK=off go build -mod=readonly ./pkg/sql/plan
  • GOWORK=off go vet -mod=readonly ./pkg/sql/plan
  • focused DML error propagation and fallback tests
  • full ./pkg/sql/plan test package via the repository CGo test wrapper

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner August 5, 2026 11:13
@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 Author

Choose a reason for hiding this comment

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

Deep review verdict: APPROVE

GitHub does not allow a pull request author to approve their own PR, so this verdict is submitted as a COMMENTED review.

Reviewed exact head: 7643824e8b06ba86eb5fa91fac988415dbaebcee

No blocking findings.

Review coverage:

  • Traced the INSERT, LOAD, and DELETE modern-planner error exits through BuildPlan and their legacy fallback boundaries.
  • Confirmed all unsafe production err.(*moerr.Error) assertions in those DML routing paths are removed; UPDATE already uses classified routing and REPLACE has no legacy fallback.
  • Confirmed non-MO errors, context cancellation/deadline errors, and wrapped cancellation are returned without triggering legacy planning, while genuine ErrUnsupportedDML still reaches the intended fallback.
  • Audited Q1-Q3 unhappy paths: this change introduces no resource ownership, waits, goroutines, or unbounded accumulation.
  • Verified the regression tests exercise the public BuildPlan path and include both negative propagation cases and positive fallback controls.

Differential root-cause proof:

  • Incident build 2758eb1d3: dml_context.go returns the resolver error unchanged, then bindAndOptimizeLoadQuery at the issue-reported build.go:289 unconditionally asserts err.(*moerr.Error).
  • The same minimal ParseOne -> BuildPlan -> LOAD -> Resolve plain error test fails on parent f526bc745908a8663051ad44fd378e23b1c98ef2 with interface conversion: error is *errors.errorString, not *moerr.Error.
  • The identical test and assertions pass on exact head 7643824e8b06ba86eb5fa91fac988415dbaebcee; the original plain error is returned and remains discoverable via errors.Is.

Local validation:

  • GOWORK=off go list -mod=readonly ./pkg/sql/plan
  • controlled-CGo go build -mod=readonly ./pkg/sql/plan
  • controlled-CGo go vet -mod=readonly ./pkg/sql/plan
  • focused DML error/fallback regression tests
  • controlled-CGo full ./pkg/sql/plan test suite
  • isolated parent-fail / exact-head-pass root-cause differential

All local validation passed on the reviewed head. GitHub CI jobs were still in progress when the original code review was submitted.

XuPeng-SH added a commit that referenced this pull request Aug 5, 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 #26730

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

Planner fallback routing accepted the general `error` interface, but
INSERT,
LOAD, and DELETE assumed every binder error was a `*moerr.Error`.
Storage
cancellation, deadlines, and other ordinary Go errors could therefore
panic
while checking for `ErrUnsupportedDML`.

This change:

- uses the existing safe `moerr.IsMoErrCode` predicate at every affected
DML
  fallback boundary;
- preserves non-MO errors and wrapped cancellation errors without
converting
  or swallowing them;
- keeps the existing legacy fallback behavior for genuine
  `ErrUnsupportedDML`;
- adds a systematic matrix covering INSERT, LOAD, DELETE, UPDATE, and
REPLACE
against cancellation, deadline, plain, and wrapped errors, plus positive
  fallback controls.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/sql/plan`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/plan`
- focused DML error propagation and fallback tests
- full `./pkg/sql/plan` test package via the repository CGo test wrapper
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#26730

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

Planner fallback routing accepted the general `error` interface, but
INSERT,
LOAD, and DELETE assumed every binder error was a `*moerr.Error`.
Storage
cancellation, deadlines, and other ordinary Go errors could therefore
panic
while checking for `ErrUnsupportedDML`.

This change:

- uses the existing safe `moerr.IsMoErrCode` predicate at every affected
DML
  fallback boundary;
- preserves non-MO errors and wrapped cancellation errors without
converting
  or swallowing them;
- keeps the existing legacy fallback behavior for genuine
  `ErrUnsupportedDML`;
- adds a systematic matrix covering INSERT, LOAD, DELETE, UPDATE, and
REPLACE
against cancellation, deadline, plain, and wrapped errors, plus positive
  fallback controls.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/sql/plan`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/plan`
- focused DML error propagation and fallback tests
- full `./pkg/sql/plan` test package via the repository CGo test wrapper
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#26730

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

Planner fallback routing accepted the general `error` interface, but
INSERT,
LOAD, and DELETE assumed every binder error was a `*moerr.Error`.
Storage
cancellation, deadlines, and other ordinary Go errors could therefore
panic
while checking for `ErrUnsupportedDML`.

This change:

- uses the existing safe `moerr.IsMoErrCode` predicate at every affected
DML
  fallback boundary;
- preserves non-MO errors and wrapped cancellation errors without
converting
  or swallowing them;
- keeps the existing legacy fallback behavior for genuine
  `ErrUnsupportedDML`;
- adds a systematic matrix covering INSERT, LOAD, DELETE, UPDATE, and
REPLACE
against cancellation, deadline, plain, and wrapped errors, plus positive
  fallback controls.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/sql/plan`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/plan`
- focused DML error propagation and fallback tests
- full `./pkg/sql/plan` test package via the repository CGo test wrapper
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#26730

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

Planner fallback routing accepted the general `error` interface, but
INSERT,
LOAD, and DELETE assumed every binder error was a `*moerr.Error`.
Storage
cancellation, deadlines, and other ordinary Go errors could therefore
panic
while checking for `ErrUnsupportedDML`.

This change:

- uses the existing safe `moerr.IsMoErrCode` predicate at every affected
DML
  fallback boundary;
- preserves non-MO errors and wrapped cancellation errors without
converting
  or swallowing them;
- keeps the existing legacy fallback behavior for genuine
  `ErrUnsupportedDML`;
- adds a systematic matrix covering INSERT, LOAD, DELETE, UPDATE, and
REPLACE
against cancellation, deadline, plain, and wrapped errors, plus positive
  fallback controls.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/sql/plan`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/plan`
- focused DML error propagation and fallback tests
- full `./pkg/sql/plan` test package via the repository CGo test wrapper

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.

[Bug] Chaos (2758eb1): LOAD DATA INLINE panics in bindAndOptimizeLoadQuery — error is *errors.errorString, not *moerr.Error

2 participants