Repository navigation
Conversation
365654a to
d782957
Compare
Merge Queue Status
This pull request spent 1 hour 59 minutes 59 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #26426 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
…gin#26426) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26131 ## What this PR does / why we need it: PR matrixorigin#26331 introduced conservative reuse for eligible multi-reference CTEs: one bounded, query-scoped materialized producer with independent `SINK_SCAN` readers. It was fully reverted by matrixorigin#26418 after TPCH Q15 failed on multi-CN execution. This PR now explicitly restores the final reviewed matrixorigin#26331 implementation and adds the targeted multi-CN correction as a separate second commit. The restored code includes the post-review ownership and spill fixes from matrixorigin#26331; it is not the earlier version that shared caller-owned batches or failed when runtime cardinality exceeded the planner estimate. The multi-CN failure occurred when the materialized producer contained several shuffle buckets per CN. `compileSinkNode` attached every bucket directly below the coordinator merge, so a submitted remote bucket retained local dispatch registrations targeting sibling buckets outside its `RemoteRun` tree. The standalone remote-pipeline guard rejected that tree. The second commit reuses `groupShuffleBucketsByCNIfNeeded` before the coordinator merge. Same-CN buckets now form one independently executable remote producer tree, while process-local materialized state remains on the coordinator. Single-CN, non-shuffle, single-reader, rejected CTE, and ordinary streaming sink paths remain unchanged. Conflict resolution was rebuilt on latest `upstream/main` rather than mechanically applying the old diff. It preserves later main changes, including the Dispatch invalid-remote-receiver regression and derived-table alias validation. The final follow-up commit closes the remaining spill-resource gap: materialized sources now share the existing statement/CN memory, spill-disk, and file-descriptor budget; serialization and read buffers are admitted before allocation, cumulative framed spill bytes are admitted before file mutation, and each spill batch has a 64 MiB runtime cap. Cleanup and prepared reuse release every reservation exactly once. Validation evidence for final head `f26b7629d74211ce916206d23af34bc1536d5ee0` and its unchanged parent implementation: - complete non-race tests for `pkg/sql/internal/materialized`, `pkg/sql/colexec/dispatch`, `pkg/sql/colexec/merge`, `pkg/sql/compile`, `pkg/sql/plan`, and `pkg/tests/issues` - complete `-race -count=1` tests for the same packages - focused lifecycle race tests (`-count=20`), multi-CN topology test (`-count=100`), and planner CTE reuse tests (`-count=20`) before the final conflict-free latest-main rebase - production-package build and vet for all changed packages - `git diff --check` - final-head schema-v4 preflight: `PASS review=PASS validation=PENDING` - final-head exact/over-boundary disk, FD, marshal/read memory, shared-source, file-failure, cleanup, and generation-reuse tests Parent head `d782957e37a5b46af957609b7edce03640c2379a` additionally completed stock two-CN TPCH SF10 Q15 through both CN ports: supplier `33987`, revenue `2296670.4443` - row checks: lineitem `59,986,052`, supplier `100,000`, Q15 filter `2,265,119`, grouped suppliers `100,000` - `EXPLAIN`: one lineitem scan/group producer and two `Sink Scan` consumers of the same source; the second feeds `MAX(total_revenue)` - forced client cancellation at about 120 ms: no residual Q15 in `SHOW PROCESSLIST`; immediate rerun returned the correct result The parent-head local SF10 terminal is correctness and lifecycle evidence, not a strict performance claim; unrelated host load was present during the final exact-head run. ### BVT N/A. Ordinary BVT data and optimizer statistics cannot deterministically select and assert the affected combination of an eligible materialized multi-reference CTE, multi-CN cross-CN shuffle, and multiple producer buckets per CN. Equivalent coverage: - planner and issue tests assert eligibility/rejection guards, scoped CTE identity, one producer, two independent consumers, and the Q15 shape - materialized-source and Merge tests cover ownership, buffered-data-before-error, cancellation, reuse, bounded transient memory, cumulative spill/FD admission, exact cleanup, and generation reuse under `-race` - `TestMaterializedCTESinkGroupsShuffleBucketsByCN` constructs the production-shaped two-CN/two-bucket topology through `compileSinkNode` and asserts one standalone producer tree per CN - the exact-head stock two-CN SF10 SQL terminal covers the real planner/compiler/executor path ### QA Decision - required: yes - reason: this fixes a user-visible distributed SQL failure involving remote pipeline rejection, cleanup, and cancellation/reuse behavior - production entrypoint: TPCH SF10 Q15 using one shared materialized CTE producer with multiple `SINK_SCAN` consumers on a stock two-CN deployment - automated terminal coverage: exact-head topology, ownership/lifecycle, planner, and local stock two-CN SF10 evidence listed above - remaining validation: verify multi-CN Q15 result and cancellation/reuse in the QA deployment or nightly distributed environment No SQL syntax, public API, protobuf, wire, or persisted-format changes. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#26426) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26131 ## What this PR does / why we need it: PR matrixorigin#26331 introduced conservative reuse for eligible multi-reference CTEs: one bounded, query-scoped materialized producer with independent `SINK_SCAN` readers. It was fully reverted by matrixorigin#26418 after TPCH Q15 failed on multi-CN execution. This PR now explicitly restores the final reviewed matrixorigin#26331 implementation and adds the targeted multi-CN correction as a separate second commit. The restored code includes the post-review ownership and spill fixes from matrixorigin#26331; it is not the earlier version that shared caller-owned batches or failed when runtime cardinality exceeded the planner estimate. The multi-CN failure occurred when the materialized producer contained several shuffle buckets per CN. `compileSinkNode` attached every bucket directly below the coordinator merge, so a submitted remote bucket retained local dispatch registrations targeting sibling buckets outside its `RemoteRun` tree. The standalone remote-pipeline guard rejected that tree. The second commit reuses `groupShuffleBucketsByCNIfNeeded` before the coordinator merge. Same-CN buckets now form one independently executable remote producer tree, while process-local materialized state remains on the coordinator. Single-CN, non-shuffle, single-reader, rejected CTE, and ordinary streaming sink paths remain unchanged. Conflict resolution was rebuilt on latest `upstream/main` rather than mechanically applying the old diff. It preserves later main changes, including the Dispatch invalid-remote-receiver regression and derived-table alias validation. The final follow-up commit closes the remaining spill-resource gap: materialized sources now share the existing statement/CN memory, spill-disk, and file-descriptor budget; serialization and read buffers are admitted before allocation, cumulative framed spill bytes are admitted before file mutation, and each spill batch has a 64 MiB runtime cap. Cleanup and prepared reuse release every reservation exactly once. Validation evidence for final head `f26b7629d74211ce916206d23af34bc1536d5ee0` and its unchanged parent implementation: - complete non-race tests for `pkg/sql/internal/materialized`, `pkg/sql/colexec/dispatch`, `pkg/sql/colexec/merge`, `pkg/sql/compile`, `pkg/sql/plan`, and `pkg/tests/issues` - complete `-race -count=1` tests for the same packages - focused lifecycle race tests (`-count=20`), multi-CN topology test (`-count=100`), and planner CTE reuse tests (`-count=20`) before the final conflict-free latest-main rebase - production-package build and vet for all changed packages - `git diff --check` - final-head schema-v4 preflight: `PASS review=PASS validation=PENDING` - final-head exact/over-boundary disk, FD, marshal/read memory, shared-source, file-failure, cleanup, and generation-reuse tests Parent head `d782957e37a5b46af957609b7edce03640c2379a` additionally completed stock two-CN TPCH SF10 Q15 through both CN ports: supplier `33987`, revenue `2296670.4443` - row checks: lineitem `59,986,052`, supplier `100,000`, Q15 filter `2,265,119`, grouped suppliers `100,000` - `EXPLAIN`: one lineitem scan/group producer and two `Sink Scan` consumers of the same source; the second feeds `MAX(total_revenue)` - forced client cancellation at about 120 ms: no residual Q15 in `SHOW PROCESSLIST`; immediate rerun returned the correct result The parent-head local SF10 terminal is correctness and lifecycle evidence, not a strict performance claim; unrelated host load was present during the final exact-head run. ### BVT N/A. Ordinary BVT data and optimizer statistics cannot deterministically select and assert the affected combination of an eligible materialized multi-reference CTE, multi-CN cross-CN shuffle, and multiple producer buckets per CN. Equivalent coverage: - planner and issue tests assert eligibility/rejection guards, scoped CTE identity, one producer, two independent consumers, and the Q15 shape - materialized-source and Merge tests cover ownership, buffered-data-before-error, cancellation, reuse, bounded transient memory, cumulative spill/FD admission, exact cleanup, and generation reuse under `-race` - `TestMaterializedCTESinkGroupsShuffleBucketsByCN` constructs the production-shaped two-CN/two-bucket topology through `compileSinkNode` and asserts one standalone producer tree per CN - the exact-head stock two-CN SF10 SQL terminal covers the real planner/compiler/executor path ### QA Decision - required: yes - reason: this fixes a user-visible distributed SQL failure involving remote pipeline rejection, cleanup, and cancellation/reuse behavior - production entrypoint: TPCH SF10 Q15 using one shared materialized CTE producer with multiple `SINK_SCAN` consumers on a stock two-CN deployment - automated terminal coverage: exact-head topology, ownership/lifecycle, planner, and local stock two-CN SF10 evidence listed above - remaining validation: verify multi-CN Q15 result and cancellation/reuse in the QA deployment or nightly distributed environment No SQL syntax, public API, protobuf, wire, or persisted-format changes. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gin#26426) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26131 ## What this PR does / why we need it: PR matrixorigin#26331 introduced conservative reuse for eligible multi-reference CTEs: one bounded, query-scoped materialized producer with independent `SINK_SCAN` readers. It was fully reverted by matrixorigin#26418 after TPCH Q15 failed on multi-CN execution. This PR now explicitly restores the final reviewed matrixorigin#26331 implementation and adds the targeted multi-CN correction as a separate second commit. The restored code includes the post-review ownership and spill fixes from matrixorigin#26331; it is not the earlier version that shared caller-owned batches or failed when runtime cardinality exceeded the planner estimate. The multi-CN failure occurred when the materialized producer contained several shuffle buckets per CN. `compileSinkNode` attached every bucket directly below the coordinator merge, so a submitted remote bucket retained local dispatch registrations targeting sibling buckets outside its `RemoteRun` tree. The standalone remote-pipeline guard rejected that tree. The second commit reuses `groupShuffleBucketsByCNIfNeeded` before the coordinator merge. Same-CN buckets now form one independently executable remote producer tree, while process-local materialized state remains on the coordinator. Single-CN, non-shuffle, single-reader, rejected CTE, and ordinary streaming sink paths remain unchanged. Conflict resolution was rebuilt on latest `upstream/main` rather than mechanically applying the old diff. It preserves later main changes, including the Dispatch invalid-remote-receiver regression and derived-table alias validation. The final follow-up commit closes the remaining spill-resource gap: materialized sources now share the existing statement/CN memory, spill-disk, and file-descriptor budget; serialization and read buffers are admitted before allocation, cumulative framed spill bytes are admitted before file mutation, and each spill batch has a 64 MiB runtime cap. Cleanup and prepared reuse release every reservation exactly once. Validation evidence for final head `f26b7629d74211ce916206d23af34bc1536d5ee0` and its unchanged parent implementation: - complete non-race tests for `pkg/sql/internal/materialized`, `pkg/sql/colexec/dispatch`, `pkg/sql/colexec/merge`, `pkg/sql/compile`, `pkg/sql/plan`, and `pkg/tests/issues` - complete `-race -count=1` tests for the same packages - focused lifecycle race tests (`-count=20`), multi-CN topology test (`-count=100`), and planner CTE reuse tests (`-count=20`) before the final conflict-free latest-main rebase - production-package build and vet for all changed packages - `git diff --check` - final-head schema-v4 preflight: `PASS review=PASS validation=PENDING` - final-head exact/over-boundary disk, FD, marshal/read memory, shared-source, file-failure, cleanup, and generation-reuse tests Parent head `d782957e37a5b46af957609b7edce03640c2379a` additionally completed stock two-CN TPCH SF10 Q15 through both CN ports: supplier `33987`, revenue `2296670.4443` - row checks: lineitem `59,986,052`, supplier `100,000`, Q15 filter `2,265,119`, grouped suppliers `100,000` - `EXPLAIN`: one lineitem scan/group producer and two `Sink Scan` consumers of the same source; the second feeds `MAX(total_revenue)` - forced client cancellation at about 120 ms: no residual Q15 in `SHOW PROCESSLIST`; immediate rerun returned the correct result The parent-head local SF10 terminal is correctness and lifecycle evidence, not a strict performance claim; unrelated host load was present during the final exact-head run. ### BVT N/A. Ordinary BVT data and optimizer statistics cannot deterministically select and assert the affected combination of an eligible materialized multi-reference CTE, multi-CN cross-CN shuffle, and multiple producer buckets per CN. Equivalent coverage: - planner and issue tests assert eligibility/rejection guards, scoped CTE identity, one producer, two independent consumers, and the Q15 shape - materialized-source and Merge tests cover ownership, buffered-data-before-error, cancellation, reuse, bounded transient memory, cumulative spill/FD admission, exact cleanup, and generation reuse under `-race` - `TestMaterializedCTESinkGroupsShuffleBucketsByCN` constructs the production-shaped two-CN/two-bucket topology through `compileSinkNode` and asserts one standalone producer tree per CN - the exact-head stock two-CN SF10 SQL terminal covers the real planner/compiler/executor path ### QA Decision - required: yes - reason: this fixes a user-visible distributed SQL failure involving remote pipeline rejection, cleanup, and cancellation/reuse behavior - production entrypoint: TPCH SF10 Q15 using one shared materialized CTE producer with multiple `SINK_SCAN` consumers on a stock two-CN deployment - automated terminal coverage: exact-head topology, ownership/lifecycle, planner, and local stock two-CN SF10 evidence listed above - remaining validation: verify multi-CN Q15 result and cancellation/reuse in the QA deployment or nightly distributed environment No SQL syntax, public API, protobuf, wire, or persisted-format changes. --------- 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 #26131
What this PR does / why we need it:
PR #26331 introduced conservative reuse for eligible multi-reference CTEs: one bounded, query-scoped materialized producer with independent
SINK_SCANreaders. It was fully reverted by #26418 after TPCH Q15 failed on multi-CN execution.This PR now explicitly restores the final reviewed #26331 implementation and adds the targeted multi-CN correction as a separate second commit. The restored code includes the post-review ownership and spill fixes from #26331; it is not the earlier version that shared caller-owned batches or failed when runtime cardinality exceeded the planner estimate.
The multi-CN failure occurred when the materialized producer contained several shuffle buckets per CN.
compileSinkNodeattached every bucket directly below the coordinator merge, so a submitted remote bucket retained local dispatch registrations targeting sibling buckets outside itsRemoteRuntree. The standalone remote-pipeline guard rejected that tree.The second commit reuses
groupShuffleBucketsByCNIfNeededbefore the coordinator merge. Same-CN buckets now form one independently executable remote producer tree, while process-local materialized state remains on the coordinator. Single-CN, non-shuffle, single-reader, rejected CTE, and ordinary streaming sink paths remain unchanged.Conflict resolution was rebuilt on latest
upstream/mainrather than mechanically applying the old diff. It preserves later main changes, including the Dispatch invalid-remote-receiver regression and derived-table alias validation.The final follow-up commit closes the remaining spill-resource gap: materialized sources now share the existing statement/CN memory, spill-disk, and file-descriptor budget; serialization and read buffers are admitted before allocation, cumulative framed spill bytes are admitted before file mutation, and each spill batch has a 64 MiB runtime cap. Cleanup and prepared reuse release every reservation exactly once.
Validation evidence for final head
f26b7629d74211ce916206d23af34bc1536d5ee0and its unchanged parent implementation:pkg/sql/internal/materialized,pkg/sql/colexec/dispatch,pkg/sql/colexec/merge,pkg/sql/compile,pkg/sql/plan, andpkg/tests/issues-race -count=1tests for the same packages-count=20), multi-CN topology test (-count=100), and planner CTE reuse tests (-count=20) before the final conflict-free latest-main rebasegit diff --checkPASS review=PASS validation=PENDINGParent head
d782957e37a5b46af957609b7edce03640c2379aadditionally completed stock two-CN TPCH SF10 Q15 through both CN ports: supplier33987, revenue2296670.444359,986,052, supplier100,000, Q15 filter2,265,119, grouped suppliers100,000EXPLAIN: one lineitem scan/group producer and twoSink Scanconsumers of the same source; the second feedsMAX(total_revenue)SHOW PROCESSLIST; immediate rerun returned the correct resultThe parent-head local SF10 terminal is correctness and lifecycle evidence, not a strict performance claim; unrelated host load was present during the final exact-head run.
BVT
N/A. Ordinary BVT data and optimizer statistics cannot deterministically select and assert the affected combination of an eligible materialized multi-reference CTE, multi-CN cross-CN shuffle, and multiple producer buckets per CN.
Equivalent coverage:
-raceTestMaterializedCTESinkGroupsShuffleBucketsByCNconstructs the production-shaped two-CN/two-bucket topology throughcompileSinkNodeand asserts one standalone producer tree per CNQA Decision
SINK_SCANconsumers on a stock two-CN deploymentNo SQL syntax, public API, protobuf, wire, or persisted-format changes.