Skip to content

fix(compile): normalize materialized CTE spill rejection - #27109

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aunjgr:fix/27106-materialized-cte-budget-error
Aug 13, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aunjgr:fix/27106-materialized-cte-budget-error

Conversation

@aunjgr

@aunjgr aunjgr commented Aug 13, 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:

issue #27106

What this PR does / why we need it:

Materialized CTE spill uses the shared HashBuild disk/FD budget, but its compile-layer adapter previously returned raw admission errors. A cumulative spill-file growth rejection could therefore be published to dependent readers as 20101 internal error, while a HashJoin consumer could independently normalize the same failure to 3015 resource exhausted. Which concurrent scope reached the coordinator first determined the client-visible error.

This change normalizes terminal budget admission errors at the materialized spill adapter before the source can publish them. It covers both initial disk/FD reservations and later disk-reservation growth, while preserving lifecycle/accounting failures unchanged through hashbuild.TerminalBudgetError.

The regression now proves both initial and cumulative disk rejection return resource exhaustion with actionable requested/used/limit details and do not retain the raw admission sentinel.

Validation:

  • GOWORK=off go list -mod=readonly ./pkg/sql/compile
  • GOWORK=off go build -mod=readonly ./pkg/sql/compile
  • GOWORK=off go vet -mod=readonly ./pkg/sql/compile
  • .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s -run '^TestMaterializedSpillBudgetUsesProcessLimits$' ./pkg/sql/compile
  • .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=300s ./pkg/sql/compile
  • git diff --check

No SQL syntax, public API, wire format, or persisted format changes.

@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 review: no blocking findings. The materialized spill adapter now normalizes initial spill-disk/FD admissions and cumulative disk Grow rejection at the terminal no-recovery boundary, while TerminalBudgetError preserves lifecycle/accounting failures. The wrapper delegates Release to the original reservation, and rejected growth leaves the charged size unchanged, so cleanup remains balanced. Verified at f1132e7: the focused regression and full compile/materialized/hashbuild package tests pass; the same Grow oracle fails on the PR base with the raw admission error.

@XuPeng-SH
XuPeng-SH merged commit 0fc87ec into matrixorigin:main Aug 13, 2026
24 checks passed
@aunjgr
aunjgr deleted the fix/27106-materialized-cte-budget-error branch August 14, 2026 03:11
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#27109)

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

issue matrixorigin#27106

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

Materialized CTE spill uses the shared HashBuild disk/FD budget, but its
compile-layer adapter previously returned raw admission errors. A
cumulative spill-file growth rejection could therefore be published to
dependent readers as `20101 internal error`, while a HashJoin consumer
could independently normalize the same failure to `3015 resource
exhausted`. Which concurrent scope reached the coordinator first
determined the client-visible error.

This change normalizes terminal budget admission errors at the
materialized spill adapter before the source can publish them. It covers
both initial disk/FD reservations and later disk-reservation growth,
while preserving lifecycle/accounting failures unchanged through
`hashbuild.TerminalBudgetError`.

The regression now proves both initial and cumulative disk rejection
return resource exhaustion with actionable requested/used/limit details
and do not retain the raw admission sentinel.

Validation:

- `GOWORK=off go list -mod=readonly ./pkg/sql/compile`
- `GOWORK=off go build -mod=readonly ./pkg/sql/compile`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s
-run '^TestMaterializedSpillBudgetUsesProcessLimits$' ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=300s
./pkg/sql/compile`
- `git diff --check`

No SQL syntax, public API, wire format, or persisted format changes.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#27109)

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

issue matrixorigin#27106

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

Materialized CTE spill uses the shared HashBuild disk/FD budget, but its
compile-layer adapter previously returned raw admission errors. A
cumulative spill-file growth rejection could therefore be published to
dependent readers as `20101 internal error`, while a HashJoin consumer
could independently normalize the same failure to `3015 resource
exhausted`. Which concurrent scope reached the coordinator first
determined the client-visible error.

This change normalizes terminal budget admission errors at the
materialized spill adapter before the source can publish them. It covers
both initial disk/FD reservations and later disk-reservation growth,
while preserving lifecycle/accounting failures unchanged through
`hashbuild.TerminalBudgetError`.

The regression now proves both initial and cumulative disk rejection
return resource exhaustion with actionable requested/used/limit details
and do not retain the raw admission sentinel.

Validation:

- `GOWORK=off go list -mod=readonly ./pkg/sql/compile`
- `GOWORK=off go build -mod=readonly ./pkg/sql/compile`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s
-run '^TestMaterializedSpillBudgetUsesProcessLimits$' ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=300s
./pkg/sql/compile`
- `git diff --check`

No SQL syntax, public API, wire format, or persisted format changes.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#27109)

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

issue matrixorigin#27106

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

Materialized CTE spill uses the shared HashBuild disk/FD budget, but its
compile-layer adapter previously returned raw admission errors. A
cumulative spill-file growth rejection could therefore be published to
dependent readers as `20101 internal error`, while a HashJoin consumer
could independently normalize the same failure to `3015 resource
exhausted`. Which concurrent scope reached the coordinator first
determined the client-visible error.

This change normalizes terminal budget admission errors at the
materialized spill adapter before the source can publish them. It covers
both initial disk/FD reservations and later disk-reservation growth,
while preserving lifecycle/accounting failures unchanged through
`hashbuild.TerminalBudgetError`.

The regression now proves both initial and cumulative disk rejection
return resource exhaustion with actionable requested/used/limit details
and do not retain the raw admission sentinel.

Validation:

- `GOWORK=off go list -mod=readonly ./pkg/sql/compile`
- `GOWORK=off go build -mod=readonly ./pkg/sql/compile`
- `GOWORK=off go vet -mod=readonly ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s
-run '^TestMaterializedSpillBudgetUsesProcessLimits$' ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=300s
./pkg/sql/compile`
- `git diff --check`

No SQL syntax, public API, wire format, or persisted format changes.

---------

Co-authored-by: XuPeng-SH <[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 kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants