Repository navigation
fix(compile): validate distributed shuffle reuse topology - #25987
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 completed on 2aee1d3. I traced logical shuffle reuse through physical scope materialization, stage-node/bucket ordering, local/remote dispatch index wiring, hash-build/join consumption, multi-CN DEDUP normalization, and cleanup/wait boundedness. No blocking findings.
Verified locally: focused topology regressions x20; focused race; full pkg/sql/compile and full race; pkg/sql/colexec/dispatch; go build and go vet. I also clean-merged latest main a327eaa and reran the full compile package plus focused race successfully.
Ubuntu UT and SCA are green. Compose/standalone/coverage jobs were still running at review time.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No actionable regressions found. The topology validation correctly prevents invalid distributed reuse and preserves valid reuse; existing review and CI evidence are consistent.
…in#25987) ## 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#25930 ## What this PR does / why we need it: A logical `ShuffleMethod_Reuse` decision does not by itself guarantee that the compiled probe scopes have the physical layout required by a distributed shuffle join. A packed local scope (`Mcpu = DOP`) represents all local buckets, but the distributed reuse path treated that single scope as one bucket. The build shuffle could therefore emit bucket N to a dispatch with only one receiver, causing the reported `shuffleToAllFunc` index-out-of-range panic. This change reuses distributed probe scopes only when there is exactly one `Mcpu=1` scope per global bucket in stage-node order. Otherwise it materializes the normal distributed shuffle layout. Multi-CN DEDUP also falls back because its scope normalization merges the per-bucket layout before dispatch wiring. Regression coverage includes packed-scope fallback, valid materialized reuse, misordered multi-CN scopes, multi-CN DEDUP normalization, and a focused BVT using a shuffled `DISTINCT` probe with a merged `UNION ALL` build. The BVT panics on unpatched main with `index out of range [1] with length 1` and passes 18/18 statements with this fix. Validation: - `make build` - `go vet -mod=readonly ./pkg/sql/compile` with repository CGo flags - `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s ./pkg/sql/compile` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -v -count=1 -timeout=240s -run '^TestDistributedShuffleJoin' ./pkg/sql/compile` - `mo-tester` BVT: `shuffle_reuse_topology.sql` (18/18) Co-authored-by: XuPeng-SH <[email protected]>
…in#25987) ## 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#25930 ## What this PR does / why we need it: A logical `ShuffleMethod_Reuse` decision does not by itself guarantee that the compiled probe scopes have the physical layout required by a distributed shuffle join. A packed local scope (`Mcpu = DOP`) represents all local buckets, but the distributed reuse path treated that single scope as one bucket. The build shuffle could therefore emit bucket N to a dispatch with only one receiver, causing the reported `shuffleToAllFunc` index-out-of-range panic. This change reuses distributed probe scopes only when there is exactly one `Mcpu=1` scope per global bucket in stage-node order. Otherwise it materializes the normal distributed shuffle layout. Multi-CN DEDUP also falls back because its scope normalization merges the per-bucket layout before dispatch wiring. Regression coverage includes packed-scope fallback, valid materialized reuse, misordered multi-CN scopes, multi-CN DEDUP normalization, and a focused BVT using a shuffled `DISTINCT` probe with a merged `UNION ALL` build. The BVT panics on unpatched main with `index out of range [1] with length 1` and passes 18/18 statements with this fix. Validation: - `make build` - `go vet -mod=readonly ./pkg/sql/compile` with repository CGo flags - `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s ./pkg/sql/compile` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -v -count=1 -timeout=240s -run '^TestDistributedShuffleJoin' ./pkg/sql/compile` - `mo-tester` BVT: `shuffle_reuse_topology.sql` (18/18) Co-authored-by: XuPeng-SH <[email protected]>
…in#25987) ## 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#25930 ## What this PR does / why we need it: A logical `ShuffleMethod_Reuse` decision does not by itself guarantee that the compiled probe scopes have the physical layout required by a distributed shuffle join. A packed local scope (`Mcpu = DOP`) represents all local buckets, but the distributed reuse path treated that single scope as one bucket. The build shuffle could therefore emit bucket N to a dispatch with only one receiver, causing the reported `shuffleToAllFunc` index-out-of-range panic. This change reuses distributed probe scopes only when there is exactly one `Mcpu=1` scope per global bucket in stage-node order. Otherwise it materializes the normal distributed shuffle layout. Multi-CN DEDUP also falls back because its scope normalization merges the per-bucket layout before dispatch wiring. Regression coverage includes packed-scope fallback, valid materialized reuse, misordered multi-CN scopes, multi-CN DEDUP normalization, and a focused BVT using a shuffled `DISTINCT` probe with a merged `UNION ALL` build. The BVT panics on unpatched main with `index out of range [1] with length 1` and passes 18/18 statements with this fix. Validation: - `make build` - `go vet -mod=readonly ./pkg/sql/compile` with repository CGo flags - `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s ./pkg/sql/compile` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -v -count=1 -timeout=240s -run '^TestDistributedShuffleJoin' ./pkg/sql/compile` - `mo-tester` BVT: `shuffle_reuse_topology.sql` (18/18) Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #25930
What this PR does / why we need it:
A logical
ShuffleMethod_Reusedecision does not by itself guarantee that thecompiled probe scopes have the physical layout required by a distributed
shuffle join. A packed local scope (
Mcpu = DOP) represents all local buckets,but the distributed reuse path treated that single scope as one bucket. The
build shuffle could therefore emit bucket N to a dispatch with only one
receiver, causing the reported
shuffleToAllFuncindex-out-of-range panic.This change reuses distributed probe scopes only when there is exactly one
Mcpu=1scope per global bucket in stage-node order. Otherwise it materializesthe normal distributed shuffle layout. Multi-CN DEDUP also falls back because
its scope normalization merges the per-bucket layout before dispatch wiring.
Regression coverage includes packed-scope fallback, valid materialized reuse,
misordered multi-CN scopes, multi-CN DEDUP normalization, and a focused BVT
using a shuffled
DISTINCTprobe with a mergedUNION ALLbuild. The BVTpanics on unpatched main with
index out of range [1] with length 1and passes18/18 statements with this fix.
Validation:
make buildgo vet -mod=readonly ./pkg/sql/compilewith repository CGo flags.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=240s ./pkg/sql/compile.agents/skills/mo-dev/scripts/mo-cgo-test -race -v -count=1 -timeout=240s -run '^TestDistributedShuffleJoin' ./pkg/sql/compilemo-testerBVT:shuffle_reuse_topology.sql(18/18)