Repository navigation
fix(colexec): report materialized CTE spill stats - #27110
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed against main@76f62df1 (merge-base 76f62df), head 1fb3be0.
No blocking findings. The per-append stats remain under the source ownership/locking boundary, report spill only after the full framed record is written, preserve the existing Append API, and attribute deltas exactly once to the materialized producer analyzer. I traced producer -> shared source -> spill/read -> Reset/reader release -> reuse and the physical-plan aggregation path; no new leak, wait-for, unbounded-growth, generation, compatibility, or material hot-path-cost issue was found.
Validation on the reviewed head: changed-package build/vet/full tests; focused materialized source/dispatch/merge/compile tests; existing public SQL two-consumer CTE integration regression; focused race stress at N=100 for all new/modified tests; and full owning-package race runs.
## 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#27107 ## What this PR does / why we need it: Materialized CTE spill is owned by the shared source, but the producer dispatch previously reported only the source's retained memory. As a result, runtime spill reservations were real while `EXPLAIN ANALYZE` showed no spill on any operator. This change returns the exact storage effect of each source append and attributes successful spill-byte and spill-row deltas to the materialized producer's operator analyzer. A spill is reported only after the complete framed record is written, and it is counted once at the producer rather than once per reader. Regression coverage verifies zero spill for retained batches, exact framed-record accounting for source spill, producer analyzer attribution, source reuse, and race safety. Validation: - `go build -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch` - `go vet -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch` - full tests for `./pkg/sql/internal/materialized` and `./pkg/sql/colexec/dispatch` - focused `Test_explainResourceOverview` in `./pkg/sql/compile` - full owning-package race tests and 100 race-stressed iterations of the new source/dispatch paths Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## 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#27107 ## What this PR does / why we need it: Materialized CTE spill is owned by the shared source, but the producer dispatch previously reported only the source's retained memory. As a result, runtime spill reservations were real while `EXPLAIN ANALYZE` showed no spill on any operator. This change returns the exact storage effect of each source append and attributes successful spill-byte and spill-row deltas to the materialized producer's operator analyzer. A spill is reported only after the complete framed record is written, and it is counted once at the producer rather than once per reader. Regression coverage verifies zero spill for retained batches, exact framed-record accounting for source spill, producer analyzer attribution, source reuse, and race safety. Validation: - `go build -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch` - `go vet -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch` - full tests for `./pkg/sql/internal/materialized` and `./pkg/sql/colexec/dispatch` - focused `Test_explainResourceOverview` in `./pkg/sql/compile` - full owning-package race tests and 100 race-stressed iterations of the new source/dispatch paths Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## 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#27107 ## What this PR does / why we need it: Materialized CTE spill is owned by the shared source, but the producer dispatch previously reported only the source's retained memory. As a result, runtime spill reservations were real while `EXPLAIN ANALYZE` showed no spill on any operator. This change returns the exact storage effect of each source append and attributes successful spill-byte and spill-row deltas to the materialized producer's operator analyzer. A spill is reported only after the complete framed record is written, and it is counted once at the producer rather than once per reader. Regression coverage verifies zero spill for retained batches, exact framed-record accounting for source spill, producer analyzer attribution, source reuse, and race safety. Validation: - `go build -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch` - `go vet -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch` - full tests for `./pkg/sql/internal/materialized` and `./pkg/sql/colexec/dispatch` - focused `Test_explainResourceOverview` in `./pkg/sql/compile` - full owning-package race tests and 100 race-stressed iterations of the new source/dispatch paths Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #27107
What this PR does / why we need it:
Materialized CTE spill is owned by the shared source, but the producer dispatch previously reported only the source's retained memory. As a result, runtime spill reservations were real while
EXPLAIN ANALYZEshowed no spill on any operator.This change returns the exact storage effect of each source append and attributes successful spill-byte and spill-row deltas to the materialized producer's operator analyzer. A spill is reported only after the complete framed record is written, and it is counted once at the producer rather than once per reader.
Regression coverage verifies zero spill for retained batches, exact framed-record accounting for source spill, producer analyzer attribution, source reuse, and race safety.
Validation:
go build -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatchgo vet -mod=readonly ./pkg/sql/internal/materialized ./pkg/sql/colexec/dispatch./pkg/sql/internal/materializedand./pkg/sql/colexec/dispatchTest_explainResourceOverviewin./pkg/sql/compile