Repository navigation
fix(morpc): terminate pending work during backend and stream close - #26004
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 78ab12de83c34e483a4624d277b50534d16ec95d; no blocking correctness or liveness issue found.
I traced the complete backend/stream/future ownership, lock ordering, wait-for graph, and reuse generation boundary:
Stream.Close(false)cancels the stream-local delivery context before acquiring the exclusive stream lock, so a response blocked on a full receive channel releases its read lock and close can drain/terminate it;- stream unregister now happens after releasing
s.mu, and backend removal releasesrb.mubefore takingstateMuthroughUnlock, removing both relevant ABBA edges; - stream objects/channels/contexts are no longer pooled or externally reused, so an old handle cannot close or consume a later stream generation;
- backend close stops the write loop, disconnects transport, waits for the read loop, then fails response-waiting futures with
backendClosedbefore deleting tracking entries; response and close cannot both terminally notify a Future; - queued writes, stream receive channels, and tracking maps have fixed capacity or explicit removal paths; no new unbounded retention was introduced.
Q1: one effective cleanup owner remains on success, error, repeated close, and finalizer paths. Q2: every changed channel/lock wait has a cancellation or transport-close termination edge. Q3: removal of the stream pool eliminates the backend↔pooled-stream retention cycle and all changed accumulations remain bounded.
Validation:
git diff --check origin/main...HEAD- focused close/lock-order/generation tests under
-race -count=50 - full
go test -race -count=1 ./pkg/common/morpc go test ./pkg/cnservice/cnclient- clean merge with current
origin/main, followed by fresh MORPC race and cnclient tests - required CI is green, including UT, SCA, CodeQL, multi-CN/proxy BVT, coverage, and Summary
Merge Queue Status
This pull request spent 18 minutes 47 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #26004 has been merged manually at e917fbf HintYou were too fast! Tick the box to put this pull request back in the merge queue (same as
|
…atrixorigin#26004) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25943 Fixes matrixorigin#25945 ## What this PR does / why we need it: - cancels a stream before waiting for its lock, so a full receive channel cannot block Stream.Close(false) - gives each stream an independent handle, receive channel, and cancellation context instead of reusing externally visible stream objects - stops backend I/O and closes the transport before failing all response-waiting Futures with backendClosed - releases the backend map mutex before taking backend state locks during stream removal - adds deterministic close, lock-order, generation-isolation, and race regressions ## Testing - make thirdparties - mo-cgo-test -race -count=20 focused MORPC close regressions - mo-cgo-test ./pkg/common/morpc - mo-cgo-test -race ./pkg/common/morpc - go build ./pkg/common/morpc - go vet ./pkg/common/morpc - mo-cgo-test ./pkg/cnservice/cnclient Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…atrixorigin#26004) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25943 Fixes matrixorigin#25945 ## What this PR does / why we need it: - cancels a stream before waiting for its lock, so a full receive channel cannot block Stream.Close(false) - gives each stream an independent handle, receive channel, and cancellation context instead of reusing externally visible stream objects - stops backend I/O and closes the transport before failing all response-waiting Futures with backendClosed - releases the backend map mutex before taking backend state locks during stream removal - adds deterministic close, lock-order, generation-isolation, and race regressions ## Testing - make thirdparties - mo-cgo-test -race -count=20 focused MORPC close regressions - mo-cgo-test ./pkg/common/morpc - mo-cgo-test -race ./pkg/common/morpc - go build ./pkg/common/morpc - go vet ./pkg/common/morpc - mo-cgo-test ./pkg/cnservice/cnclient Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…atrixorigin#26004) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#25943 Fixes matrixorigin#25945 ## What this PR does / why we need it: - cancels a stream before waiting for its lock, so a full receive channel cannot block Stream.Close(false) - gives each stream an independent handle, receive channel, and cancellation context instead of reusing externally visible stream objects - stops backend I/O and closes the transport before failing all response-waiting Futures with backendClosed - releases the backend map mutex before taking backend state locks during stream removal - adds deterministic close, lock-order, generation-isolation, and race regressions ## Testing - make thirdparties - mo-cgo-test -race -count=20 focused MORPC close regressions - mo-cgo-test ./pkg/common/morpc - mo-cgo-test -race ./pkg/common/morpc - go build ./pkg/common/morpc - go vet ./pkg/common/morpc - mo-cgo-test ./pkg/cnservice/cnclient 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 #25943
Fixes #25945
What this PR does / why we need it:
Testing