Repository navigation
fix(plan): safely classify DML planner errors - #26731
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
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
BuildPlanand 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
ErrUnsupportedDMLstill 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
BuildPlanpath and include both negative propagation cases and positive fallback controls.
Differential root-cause proof:
- Incident build
2758eb1d3:dml_context.goreturns the resolver error unchanged, thenbindAndOptimizeLoadQueryat the issue-reportedbuild.go:289unconditionally assertserr.(*moerr.Error). - The same minimal
ParseOne -> BuildPlan -> LOAD -> Resolve plain errortest fails on parentf526bc745908a8663051ad44fd378e23b1c98ef2withinterface 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 viaerrors.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/plantest 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.
## 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
## 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
## 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
## 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
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26730
What this PR does / why we need it:
Planner fallback routing accepted the general
errorinterface, but INSERT,LOAD, and DELETE assumed every binder error was a
*moerr.Error. Storagecancellation, deadlines, and other ordinary Go errors could therefore panic
while checking for
ErrUnsupportedDML.This change:
moerr.IsMoErrCodepredicate at every affected DMLfallback boundary;
or swallowing them;
ErrUnsupportedDML;against cancellation, deadline, plain, and wrapped errors, plus positive
fallback controls.
Validation:
GOWORK=off go build -mod=readonly ./pkg/sql/planGOWORK=off go vet -mod=readonly ./pkg/sql/plan./pkg/sql/plantest package via the repository CGo test wrapper