Skip to content

fix(shuffle): guard stop writing by pool ownership - #28964

Merged
XuPeng-SH merged 2 commits into
mainfrom
codex/issue-28313-fix
Sep 16, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
codex/issue-28313-fix

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Summary

  • Require a Shuffle to have successfully acquired a shared-pool holder before publishing stop-writing completion.
  • Add a deterministic regression covering aborted drain-all admission followed by pipeline cleanup.

Root cause

The latest #28313 recurrence on CI run 34903702725/job 104175702889 ended with shuffle pool too many stoppers! from ShufflePool.stopWriting during Shuffle.Reset. Shuffle.Prepare can retain the pool while leaving ctr.held false when admission is rejected, but the common stopWritingOnce helper previously counted that rejected operator as a stopper. That violates the pool ownership invariant and can panic or consume another holder's completion count.

The guard is placed in the common helper, so admitted synchronous and asynchronous producer paths retain the existing exactly-once behavior.

Validation

  • Focused regression: normal and race pass.
  • Removing only the guard makes the regression fail with shuffle pool too many stoppers! through Shuffle.Reset and pipeline cleanup; restoring it passes.
  • pkg/sql/colexec/shuffle and pkg/vm/pipeline: normal and race pass.
  • TestIssue28313EmptyRemoteDispatch: normal pass (12.86s) and race pass (17.0s).
  • go vet ./pkg/sql/colexec/shuffle and git diff --check pass.

Scope

This fixes the current-base cleanup ownership violation evidenced by the CI panic. It does not by itself prove that the full intermittent cross-CN #28313 recurrence, preceding cancellation, or connector terminal-send timeout is eliminated; those need separate distributed evidence.

Refs #28313

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force deep review 结果(当前 head 968e72d):

未发现 confirmed blocking defect。shuffle.go:404 正确排除 rejected holder;admitted holder 保留 writingStopped guard;held 在 producer launch 前设置;Reset 会等待 producerDone 后再清 ownership/runtime state;现有 cancellation/end channel、consumer-close、final-holder cleanup 和 cleaned-pool admission 均未发现回归。

Low/non-blocking 测试缺口:shuffle_test.go:79 只测试 zero-holder rejection。建议增加 admitted sibling + rejected operator,断言 rejected cleanup 不改变 counters,且 sibling completion 恰好释放资源一次,防止误消费其他 holder 的 completion count。

Exact-head TestShuffleFailedAdmissionCleanup 在 -race -count=100 下通过;更广泛 normal/race 为作者报告,CI 当时 pending。此 review 不等同于已解决 broader distributed #28313 recurrence。

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第二次 force deep review(当前 head 968e72d):

再次确认无 blocking defect。shuffle.go:404-408 正确排除 rejected holders;held 只在 hold 成功后设置;producer completion 先于 producerDone close,Reset 会 join 后再清 ownership/runtime state;blocked writer 的 space/end/context select、abort、consumer close、ready credits 和 producer cancellation 保持完整;release holder-gated,cleaned guard 和 admission rejection 防止 double cleanup/reuse race。

上次测试缺口属于 low/optional,不是 merge blocker:shuffle_test.go:73-112 已直接验证 rejected cleanup 不改变三个 counters 且可重复 cleanup,shufflepool_test.go:87-130 覆盖 deferred final cleanup/idempotence。

Pinned-head required CI、Ubuntu UT、multi-CN BVT 通过;本次 shuffle package race 因按要求提前结束未新增通过证据,但此前 -race -count=100 已通过。此结论覆盖 ownership fix,不代表 broader distributed #28313 recurrence 已消除。

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Require a Shuffle to have successfully acquired a shared-pool holder
before publishing stop-writing completion.
- Add a deterministic regression covering aborted drain-all admission
followed by pipeline cleanup.

## Root cause

The latest matrixorigin#28313 recurrence on CI run 34903702725/job 104175702889
ended with `shuffle pool too many stoppers!` from
`ShufflePool.stopWriting` during `Shuffle.Reset`. `Shuffle.Prepare` can
retain the pool while leaving `ctr.held` false when admission is
rejected, but the common `stopWritingOnce` helper previously counted
that rejected operator as a stopper. That violates the pool ownership
invariant and can panic or consume another holder's completion count.

The guard is placed in the common helper, so admitted synchronous and
asynchronous producer paths retain the existing exactly-once behavior.

## Validation

- Focused regression: normal and race pass.
- Removing only the guard makes the regression fail with `shuffle pool
too many stoppers!` through `Shuffle.Reset` and pipeline cleanup;
restoring it passes.
- `pkg/sql/colexec/shuffle` and `pkg/vm/pipeline`: normal and race pass.
- `TestIssue28313EmptyRemoteDispatch`: normal pass (12.86s) and race
pass (17.0s).
- `go vet ./pkg/sql/colexec/shuffle` and `git diff --check` pass.

## Scope

This fixes the current-base cleanup ownership violation evidenced by the
CI panic. It does not by itself prove that the full intermittent
cross-CN matrixorigin#28313 recurrence, preceding cancellation, or connector
terminal-send timeout is eliminated; those need separate distributed
evidence.

Refs matrixorigin#28313
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Require a Shuffle to have successfully acquired a shared-pool holder
before publishing stop-writing completion.
- Add a deterministic regression covering aborted drain-all admission
followed by pipeline cleanup.

## Root cause

The latest matrixorigin#28313 recurrence on CI run 34903702725/job 104175702889
ended with `shuffle pool too many stoppers!` from
`ShufflePool.stopWriting` during `Shuffle.Reset`. `Shuffle.Prepare` can
retain the pool while leaving `ctr.held` false when admission is
rejected, but the common `stopWritingOnce` helper previously counted
that rejected operator as a stopper. That violates the pool ownership
invariant and can panic or consume another holder's completion count.

The guard is placed in the common helper, so admitted synchronous and
asynchronous producer paths retain the existing exactly-once behavior.

## Validation

- Focused regression: normal and race pass.
- Removing only the guard makes the regression fail with `shuffle pool
too many stoppers!` through `Shuffle.Reset` and pipeline cleanup;
restoring it passes.
- `pkg/sql/colexec/shuffle` and `pkg/vm/pipeline`: normal and race pass.
- `TestIssue28313EmptyRemoteDispatch`: normal pass (12.86s) and race
pass (17.0s).
- `go vet ./pkg/sql/colexec/shuffle` and `git diff --check` pass.

## Scope

This fixes the current-base cleanup ownership violation evidenced by the
CI panic. It does not by itself prove that the full intermittent
cross-CN matrixorigin#28313 recurrence, preceding cancellation, or connector
terminal-send timeout is eliminated; those need separate distributed
evidence.

Refs matrixorigin#28313

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants