fix(morpc): join accepted server connections on close - #26554
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 finding — P1 / merge blocker The connection tracker is admitted too late to provide the shutdown guarantee claimed by this PR. This leaves a valid shutdown interleaving:
So The new test does not cover this boundary because it manually calls Please move the lifecycle accounting to the actual goetty admission/ownership boundary:
Please also add a deterministic regression test for the accepted-but-handler-not-yet-started state. This fixes the ownership protocol rather than relying on scheduling or a scenario-specific delay. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Requesting changes for the P1 shutdown-ownership gap documented in the prior comment.
connections.begin() executes only after the goetty handler goroutine is scheduled, while connection admission happens before that goroutine is launched. Close() can therefore seal an empty tracker and return while an already accepted handler is still queued, leaving the original goroutine-leak failure possible.
Please move accounting to the goetty admission/outer-goroutine boundary and add a deterministic accepted-but-not-yet-started regression test.
What type of PR is this?
Which issue(s) this PR fixes:
issue #26550
What this PR does / why we need it:
MORPC server shutdown previously stopped the goetty application and returned after disconnecting active sessions, but goetty did not join the admitted connection handlers. Under CI load, leak detection could therefore run while
doConnection, server write-loop, and peer backend goroutines were still unwinding.This change:
Server.Closecannot return before an accepted connection completes cleanup.Validation:
mo-cgo-test -race -count=100 -run '^TestServerCloseWaitsForAcceptedConnections$' ./pkg/common/morpcmo-cgo-test -race -count=1 ./pkg/common/morpcmo-cgo-test -count=50 -run '^TestStatusInRollingRestartCN$' ./pkg/lockservicemo-cgo-test -race -count=13 -run '^TestStatusInRollingRestartCN$' ./pkg/lockservicemo-cgo-test -race -count=1 ./pkg/lockservicego build ./pkg/common/morpc/... ./pkg/lockservice/...go vet ./pkg/common/morpc/... ./pkg/lockservice/...After merging the latest
main, both focused race regressions were rerun successfully.