You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: MORPC FIN can deadlock with session close while its ACK is pending #29560
On the current main, a server-side MORPC stream FIN can deadlock with client-session shutdown if the FIN ACK has been queued but the writer exits before completing it. This was observed during cleanup after the five SQL subtests of TestJoinCoordinatorStage had passed; the test cluster then failed to shut down. This is a transport lifecycle bug, not a SQL/query failure.
Root cause
clientSession.FinishStream held streamStateMu while waiting for the FIN send Future to complete. If the server writer exits, its deferred session close needs the same mutex before it can drain and fail queued sends. The two paths then wait on each other:
FIN waits for the queued ACK Future while holding streamStateMu.
Session close waits for streamStateMu before draining/failing that Future.
Server shutdown waits for the writer/session cleanup to finish.
Reproduction evidence
Baseline: main at 113d374b2e5167238d8411c117dfe879aef8bad6.
A deterministic white-box probe registers a stream request, queues its FIN ACK without a live writer, then concurrently calls FinishStream and session Close. On baseline, both calls remain blocked until the probe manually drains the pending Future.
CI observation: PR #29549 UT job completed all five TestJoinCoordinatorStage SQL subtests, then timed out during cluster cleanup.
Expected behavior
Session shutdown must be able to drain/fail a pending FIN ACK and let both FIN completion and server shutdown terminate, without holding the stream-state lock across a potentially blocking send completion wait.
Regression coverage
The regression is exercised by the MORPC lifecycle tests added in PR #29559, including queued FIN with no writer, writer exit/Stopper completion, duplicate FIN/later-request exclusion, and exact message/Future release accounting.
Related
This is a concrete MORPC FIN/session-close lock cycle in the broader pipeline termination/lifecycle area tracked by #24971; it is not the already-fixed client-side full receive-channel deadlock in #25943.
Activity
fix(morpc): unblock FIN teardown when writer exits (#29559)