Repository navigation
fix: prevent nested local shuffle deadlocks - #26055
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? |
|
Deep-review follow-up pushed in 02bc01a and rebased by merge on the latest main in 1992a71. Correctness:
Performance:
Risk controls:
Post-main-merge validation:
|
|
Addressed the requested change in 0b1a36a. The reset path now uses a dedicated context-aware rollback entry point, so migrateController.startClose cancellation reaches the actual TxnOperator.Rollback call. Normal SQL rollback intentionally continues to inherit the transaction context; request cancellation must not skip ordinary transaction cleanup. Added TestRoutineCloseCancelsResetRollback, which deterministically blocks inside TxnOperator.Rollback, closes the routine, and verifies both reset and waitAndClose terminate promptly. Fresh validation after the change:
|
LeftHandCold
left a comment
There was a problem hiding this comment.
Reviewed the complete PR at 0b1a36a15feaa7765d2304fcc3a938ff3398a478, including the latest reset-rollback cancellation fix. The dedicated context-aware rollback path now breaks the close/reset wait cycle without changing normal statement or cleanup rollback semantics, and the new blocking regression test covers the actual storage rollback context. I found no remaining actionable correctness or regression issue.
aptend
left a comment
There was a problem hiding this comment.
Independent re-review completed on head 0b1a36a15feaa7765d2304fcc3a938ff3398a478 against base 56735f02fd1e045685e4072289eae99bd8621b5a.
No merge-blocking findings remain. The review covered the complete diff, shuffle topology closure, frontend lifecycle/reset/close state transitions, socket liveness probing, and Q1-Q3 unhappy paths. Targeted and full owning-package tests, frontend race tests, build, vet, and diff checks passed.
|
Tick the box to add this pull request to the merge queue (same as
|
## What type of PR is this? - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes Fixes matrixorigin#25922 ## What this PR does / why we need it The unified Shuffle implementation added bounded backpressure to shared local Shuffle pools. Per-bucket credits fixed same-level hot-bucket starvation, but a finite fixed-bucket pool can still deadlock when more than one local Shuffle is duplicated into the same pull-based worker tree. The observed 16-worker wait-for cycle was: 1. an outer Shuffle writer filled its target bucket and waited for that bucket's worker; 2. the target worker was blocked in an inner Shuffle waiting for every inner writer to finish; 3. the missing inner writer was the child of the blocked outer writer, so it could only finish if the outer writer resumed pulling. This change prevents the cyclic topology instead of increasing or removing the memory bound: - keep the first fixed-bucket local Shuffle fast path; - detect a fixed-bucket Shuffle already present in a packed operator tree; - materialize a second join/group Shuffle through the existing producer scopes, bounded dispatch channels, and consumer scopes; - preserve local Shuffle reuse when no second probe Shuffle is introduced; - cancel an active request before connection cleanup waits for migration/reset or transaction rollback, so cleanup is independent of a stuck data path. The fallback remains bounded: its existing dispatch channel capacity is 32, and this PR does not change Shuffle ready credits or introduce an unbounded queue. It also does not introduce a new hard query timeout. ## Regression coverage - 16-way nested local shuffle join, on both probe and build chains; - 16-way nested local shuffle group; - fixed Shuffle below a non-root operator to cover recursive detection; - single-layer local group and reusable local join fast paths remain local; - connection cleanup cancels before a blocked lifecycle operation and before rollback. The nested-join regression failed on `origin/main` by producing one packed local scope and passes with this change by producing 16 independent bucket scopes. ## Validation - `go test -race -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend` - focused new concurrency/topology tests under `-race -count=20` - `go test -v -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend` - `go test -count=1 ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/dispatch ./pkg/sql/colexec/merge ./pkg/sql/colexec/group` - `go build ./pkg/sql/compile ./pkg/frontend` - `go vet ./pkg/sql/compile ./pkg/frontend` - `git diff --check` --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes Fixes matrixorigin#25922 ## What this PR does / why we need it The unified Shuffle implementation added bounded backpressure to shared local Shuffle pools. Per-bucket credits fixed same-level hot-bucket starvation, but a finite fixed-bucket pool can still deadlock when more than one local Shuffle is duplicated into the same pull-based worker tree. The observed 16-worker wait-for cycle was: 1. an outer Shuffle writer filled its target bucket and waited for that bucket's worker; 2. the target worker was blocked in an inner Shuffle waiting for every inner writer to finish; 3. the missing inner writer was the child of the blocked outer writer, so it could only finish if the outer writer resumed pulling. This change prevents the cyclic topology instead of increasing or removing the memory bound: - keep the first fixed-bucket local Shuffle fast path; - detect a fixed-bucket Shuffle already present in a packed operator tree; - materialize a second join/group Shuffle through the existing producer scopes, bounded dispatch channels, and consumer scopes; - preserve local Shuffle reuse when no second probe Shuffle is introduced; - cancel an active request before connection cleanup waits for migration/reset or transaction rollback, so cleanup is independent of a stuck data path. The fallback remains bounded: its existing dispatch channel capacity is 32, and this PR does not change Shuffle ready credits or introduce an unbounded queue. It also does not introduce a new hard query timeout. ## Regression coverage - 16-way nested local shuffle join, on both probe and build chains; - 16-way nested local shuffle group; - fixed Shuffle below a non-root operator to cover recursive detection; - single-layer local group and reusable local join fast paths remain local; - connection cleanup cancels before a blocked lifecycle operation and before rollback. The nested-join regression failed on `origin/main` by producing one packed local scope and passes with this change by producing 16 independent bucket scopes. ## Validation - `go test -race -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend` - focused new concurrency/topology tests under `-race -count=20` - `go test -v -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend` - `go test -count=1 ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/dispatch ./pkg/sql/colexec/merge ./pkg/sql/colexec/group` - `go build ./pkg/sql/compile ./pkg/frontend` - `go vet ./pkg/sql/compile ./pkg/frontend` - `git diff --check` --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes Fixes matrixorigin#25922 ## What this PR does / why we need it The unified Shuffle implementation added bounded backpressure to shared local Shuffle pools. Per-bucket credits fixed same-level hot-bucket starvation, but a finite fixed-bucket pool can still deadlock when more than one local Shuffle is duplicated into the same pull-based worker tree. The observed 16-worker wait-for cycle was: 1. an outer Shuffle writer filled its target bucket and waited for that bucket's worker; 2. the target worker was blocked in an inner Shuffle waiting for every inner writer to finish; 3. the missing inner writer was the child of the blocked outer writer, so it could only finish if the outer writer resumed pulling. This change prevents the cyclic topology instead of increasing or removing the memory bound: - keep the first fixed-bucket local Shuffle fast path; - detect a fixed-bucket Shuffle already present in a packed operator tree; - materialize a second join/group Shuffle through the existing producer scopes, bounded dispatch channels, and consumer scopes; - preserve local Shuffle reuse when no second probe Shuffle is introduced; - cancel an active request before connection cleanup waits for migration/reset or transaction rollback, so cleanup is independent of a stuck data path. The fallback remains bounded: its existing dispatch channel capacity is 32, and this PR does not change Shuffle ready credits or introduce an unbounded queue. It also does not introduce a new hard query timeout. ## Regression coverage - 16-way nested local shuffle join, on both probe and build chains; - 16-way nested local shuffle group; - fixed Shuffle below a non-root operator to cover recursive detection; - single-layer local group and reusable local join fast paths remain local; - connection cleanup cancels before a blocked lifecycle operation and before rollback. The nested-join regression failed on `origin/main` by producing one packed local scope and passes with this change by producing 16 independent bucket scopes. ## Validation - `go test -race -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend` - focused new concurrency/topology tests under `-race -count=20` - `go test -v -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend` - `go test -count=1 ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/dispatch ./pkg/sql/colexec/merge ./pkg/sql/colexec/group` - `go build ./pkg/sql/compile ./pkg/frontend` - `go vet ./pkg/sql/compile ./pkg/frontend` - `git diff --check` --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes
Fixes #25922
What this PR does / why we need it
The unified Shuffle implementation added bounded backpressure to shared local Shuffle pools. Per-bucket credits fixed same-level hot-bucket starvation, but a finite fixed-bucket pool can still deadlock when more than one local Shuffle is duplicated into the same pull-based worker tree.
The observed 16-worker wait-for cycle was:
This change prevents the cyclic topology instead of increasing or removing the memory bound:
The fallback remains bounded: its existing dispatch channel capacity is 32, and this PR does not change Shuffle ready credits or introduce an unbounded queue. It also does not introduce a new hard query timeout.
Regression coverage
The nested-join regression failed on
origin/mainby producing one packed local scope and passes with this change by producing 16 independent bucket scopes.Validation
go test -race -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontend-race -count=20go test -v -count=1 -timeout=600s ./pkg/sql/compile ./pkg/frontendgo test -count=1 ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/dispatch ./pkg/sql/colexec/merge ./pkg/sql/colexec/groupgo build ./pkg/sql/compile ./pkg/frontendgo vet ./pkg/sql/compile ./pkg/frontendgit diff --check