Repository navigation
fix: drain connection establishment during shutdown - #11263
Merged
ReubenBond merged 2 commits intoSep 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review tier: Lite
Findings: None
What changed in this PR
Improves connection shutdown by draining in-flight establishment and cleanup before resource disposal.
Changes:
- Adds admission gating and runner tracking.
- Handles queued and failed connection cleanup safely.
- Adds lifecycle regression tests and documentation.
| File | Description |
|---|---|
test/Orleans.Core.Tests/Networking/ConnectionManagerTests.cs |
Adds shutdown and connection lifecycle regression tests. |
src/Orleans.Core/Networking/ConnectionManager.cs |
Coordinates admission, publication, runner cleanup, and shutdown draining. |
src/Orleans.Core/Networking/Connection.cs |
Safely handles queued closure and transport cleanup. |
docs/site/src/content/docs/implementation/messaging-networking.md |
Documents connection ownership and shutdown guarantees. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Code coverage
Report-only conclusion: improved. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
This was referenced Oct 3, 2026
Closed
This was referenced Oct 12, 2026
Closed
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Shutdown can observe an empty routing table while an accepted asynchronous acquisition is waiting to publish its pending attempt. Initialization failure can also clear routing state while the connection runner is still executing middleware cleanup, allowing resource disposal before accepted work finishes.
Solution
Use the existing internal
AdmissionGateto own acquisition before its first yield through successful publication or failure cleanup. Outbound silo preamble publication remains under that original ownership; listener-owned inbound publication takes its own synchronous admission. Close admission before canceling attempts and signaling connections to terminate, then drain producers and rescan their final publications.Track outbound runners independently from routing entries and join the runner after failed initialization. Keep shutdown cancellation resources valid through producer and runner cleanup, including when a canceled host stop abandons its wait. Preserve listener accept-loop ownership and the listener's same-stage dependency on
ConnectionManager.Closed.Connection closure atomically orders queued middleware startup against shutdown, aborts the original transport even during TLS or Orleans-preamble initialization, and waits for middleware to unwind before disposing the connection context. This lets TLS restore its original transport before socket disposal joins the underlying I/O tasks. Middleware completion is signaled before the runner awaits the shared close task.
Preserve pending-attempt coalescing, fast reuse, retry backoff, and endpoint-specific closure. Focused regressions exercise unpublished admission, late creation, production
SiloConnectionpreamble publication, initialization failure/cancellation, a wrapped-stream initialization timeout with controlled cleanup, canceled host waits, coalescing/reuse, inbound rejection, and pre-start/synchronous middleware failure. The networking implementation guide describes these ownership guarantees.Independent of reminder and observer shutdown changes; no shared gate API, listener stage, or lifecycle adapter changes.
Microsoft Reviewers: Open in CodeFlow