Repository navigation
refactor: unify shuffle implementations - #25814
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.
Pull request overview
This PR refactors MatrixOne’s execution pipeline to unify the former ShuffleV2 behavior into Shuffle, removing the ShuffleV2 opcode/implementation while preserving protobuf compatibility and adding an explicit “drain all buckets” mode for distributed execution.
Changes:
- Adds
drain_all_bucketsto thepipeline.Shuffleprotobuf and wires it through pipeline (de)serialization. - Removes
ShuffleV2(opcode, debug name, code, tests, CODEOWNERS entry) and updates planning/compile logic to use a singleShuffleoperator with either local shared-pool or distributed drain-all behavior. - Reworks shuffle shared-pool lifecycle/backpressure and updates operator duplication to share generation-scoped pools without mutating reusable templates; adds targeted unit tests for pool behavior and serialization.
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| proto/pipeline.proto | Adds drain_all_buckets field to Shuffle instruction for distributed drain-all behavior. |
| pkg/vm/types.go | Reserves former ShuffleV2 opcode slot to keep later wire values stable. |
| pkg/sql/plan/ap_multi_cn_shuffle_merge_guide.md | Updates documentation to reference only shuffle (removes shuffleV2). |
| pkg/sql/compile/scope.go | Uses a shared duplication context when cloning operators for parallel scopes. |
| pkg/sql/compile/scope_test.go | Verifies duplicated shuffles share a pool per generation and do not mutate the template. |
| pkg/sql/compile/remoterun.go | Serializes/deserializes DrainAllBuckets in pipeline Shuffle instructions. |
| pkg/sql/compile/remoterun_test.go | Adds Shuffle serialization roundtrip coverage including DrainAllBuckets. |
| pkg/sql/compile/operator.go | Removes ShuffleV2 duplication path; adds duplication context to share ShufflePool across workers; updates shuffle construction helpers. |
| pkg/sql/compile/operator_test.go | Updates duplication tests to cover shared pool behavior, consumer index assignment, and join-shuffle expr/col handling. |
| pkg/sql/compile/debugTools.go | Removes shuffleV2 from debug instruction name mapping. |
| pkg/sql/compile/compile.go | Unifies join/group shuffle compilation paths; introduces local vs distributed shuffle join/group selection; sets DrainAllBuckets for distributed cases. |
| pkg/sql/compile/compile_test.go | Updates shuffle-group compilation tests for the unified local/distributed behavior. |
| pkg/sql/colexec/shuffleV2/types.go | Deleted: removes ShuffleV2 operator implementation. |
| pkg/sql/colexec/shuffleV2/shufflepool.go | Deleted: removes ShuffleV2 pool implementation. |
| pkg/sql/colexec/shuffleV2/shuffle.go | Deleted: removes ShuffleV2 execution implementation. |
| pkg/sql/colexec/shuffleV2/shuffle_test.go | Deleted: removes ShuffleV2 unit tests. |
| pkg/sql/colexec/shuffle/types.go | Adds fields needed for unified shuffle behavior (e.g., CurrentShuffleIdx, DrainAllBuckets) and updates container state/lifecycle. |
| pkg/sql/colexec/shuffle/shufflepool.go | Reworks ShufflePool into a bounded, generation-scoped shared pool with backpressure and drain-all support. |
| pkg/sql/colexec/shuffle/shufflepool_test.go | New: adds focused tests for pool stopping semantics, fairness, abort/cleanup, backpressure/resume, and memory reporting. |
| pkg/sql/colexec/shuffle/shuffle.go | Unifies Shuffle execution with resumable writes + drain-all mode and updated runtime-filter handling. |
| pkg/sql/colexec/shuffle/shuffle_test.go | Updates Shuffle tests for new drain-all semantics and adds shared-pool fixed-bucket worker coverage. |
| pkg/container/batch/batch_set.go | Adds readiness helpers (ReadyCount/ReadyDelta) and adjusts Union ownership timing for error paths. |
| pkg/container/batch/batch_set_test.go | Adds readiness/off-heap growth test coverage. |
| CODEOWNERS | Removes obsolete ShuffleV2 ownership entry. |
Files not reviewed (2)
- pkg/pb/logservice/logservice.pb.go: Generated file
- pkg/pb/pipeline/pipeline.pb.go: Generated file
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? |
|
@gouhongshen Fixed in
Added Validation on the current head:
|
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No blocking regressions found. Focused CGo tests could not run because the checkout lacks cgo/libmo.dylib.
Merge Queue Status
This pull request spent 3 hours 42 minutes 13 seconds in the queue, including 1 hour 1 minute 16 seconds running CI. Required conditions to merge
|
LeftHandCold
left a comment
There was a problem hiding this comment.
Re-reviewed current head cdb8935 in depth. No blocking correctness or regression issues remain. I checked local/shared and distributed/drain-all routing, ready-token and batch ownership, bounded backpressure/resume, child ExecStop draining, abort/reset cleanup, wait-for exits, generation-scoped pool duplication, remote serialization, and opcode compatibility. The previously raised token-claim and premature-stop issues are fixed in this head. Focused tests passed for batch, shuffle, and compile packages; shuffle pool concurrency tests also passed under -race.
Unifies the Shuffle and ShuffleV2 implementations, retaining the former V2 local shared-pool execution model in Shuffle while adding explicit drain-all-buckets behavior for distributed execution. The shared pool is generation-scoped, bounds ready and recycled batches, resumes blocked writes without losing the input batch, tracks off-heap batch memory once, and tears down safely on normal and failed pipelines. The change also removes the obsolete ShuffleV2 opcode and implementation, preserves protobuf compatibility, and regenerates protobuf bindings with `make pb`. Validation: - Focused batch, shuffle, and compile package tests - Shuffle race test - Targeted build and vet - Added executable-line coverage: 79.22% (694/876) - Relevant group and full-outer-join BVTs executed; query values matched, while the current goldens contain stale result metadata and fixed-core EXPLAIN ANALYZE output Approved by: @XuPeng-SH, @fengttt, @gouhongshen, @volgariver6, @LeftHandCold
Unifies the Shuffle and ShuffleV2 implementations, retaining the former V2 local shared-pool execution model in Shuffle while adding explicit drain-all-buckets behavior for distributed execution. The shared pool is generation-scoped, bounds ready and recycled batches, resumes blocked writes without losing the input batch, tracks off-heap batch memory once, and tears down safely on normal and failed pipelines. The change also removes the obsolete ShuffleV2 opcode and implementation, preserves protobuf compatibility, and regenerates protobuf bindings with `make pb`. Validation: - Focused batch, shuffle, and compile package tests - Shuffle race test - Targeted build and vet - Added executable-line coverage: 79.22% (694/876) - Relevant group and full-outer-join BVTs executed; query values matched, while the current goldens contain stale result metadata and fixed-core EXPLAIN ANALYZE output Approved by: @XuPeng-SH, @fengttt, @gouhongshen, @volgariver6, @LeftHandCold
Unifies the Shuffle and ShuffleV2 implementations, retaining the former V2 local shared-pool execution model in Shuffle while adding explicit drain-all-buckets behavior for distributed execution. The shared pool is generation-scoped, bounds ready and recycled batches, resumes blocked writes without losing the input batch, tracks off-heap batch memory once, and tears down safely on normal and failed pipelines. The change also removes the obsolete ShuffleV2 opcode and implementation, preserves protobuf compatibility, and regenerates protobuf bindings with `make pb`. Validation: - Focused batch, shuffle, and compile package tests - Shuffle race test - Targeted build and vet - Added executable-line coverage: 79.22% (694/876) - Relevant group and full-outer-join BVTs executed; query values matched, while the current goldens contain stale result metadata and fixed-core EXPLAIN ANALYZE output Approved by: @XuPeng-SH, @fengttt, @gouhongshen, @volgariver6, @LeftHandCold
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #24097
What this PR does / why we need it:
Unifies the Shuffle and ShuffleV2 implementations, retaining the former V2 local shared-pool execution model in Shuffle while adding explicit drain-all-buckets behavior for distributed execution.
The shared pool is generation-scoped, bounds ready and recycled batches, resumes blocked writes without losing the input batch, tracks off-heap batch memory once, and tears down safely on normal and failed pipelines. The change also removes the obsolete ShuffleV2 opcode and implementation, preserves protobuf compatibility, and regenerates protobuf bindings with
make pb.Validation: