Repository navigation
fix(networking): complete silo handshake before publication - #11447
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation preserves lifecycle behavior and includes comprehensive deterministic regression coverage.
0 open findings
What changed in this PR
Delays silo connection publication until both handshake preambles complete, preventing framed messages from preceding the local protocol preamble.
Changes:
- Moves connection publication after both preamble operations.
- Adds inbound/outbound success and write-failure regression coverage.
- Documents the handshake-ordering invariant.
| File | Description |
|---|---|
src/Orleans.Runtime/Networking/SiloConnection.cs |
Publishes only after handshake completion. |
test/Orleans.Core.Tests/Networking/ConnectionManagerTests.cs |
Adds deterministic ordering and cleanup tests. |
docs/site/src/content/docs/implementation/messaging-networking.md |
Documents publication ordering. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: current-main baseline stale. The newest successful coverage run tested ca862d8, not current main ab85a77. 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 |
…pgrade test RollingUpgrade_LocalToDistributed_NoErrors can fail its final no-error-log assertion when MembershipAgent.ValidateInitialConnectivity logs a transient, recoverable startup ping-retry failure (LogLevel.Error, event MembershipJoiningPreconditionFailure) during a newly-joining silo's pre-active connectivity check. This is pre-existing MembershipAgent behavior, unrelated to recent PRs dotnet#11431/dotnet#11447/dotnet#11426/dotnet#10187/dotnet#10772: each retriable attempt logs at error level even when a subsequent retry succeeds and the connectivity-validation loop breaks cleanly. Only exhausted retries (MaxJoinAttemptTime elapsed) throw and fail silo startup, which would already fail this test before reaching its final assertion. Add a narrow filter, consistent with the existing IsExpectedClientRoutingTableCancellation/IsExpectedDirectoryPartitionRejection filters, that excludes only this specific recovered-retry log line and surfaces the count/content of any filtered retries in test output for visibility. Fixes dotnet#11444
…pgrade test RollingUpgrade_LocalToDistributed_NoErrors can fail its final no-error-log assertion when MembershipAgent.ValidateInitialConnectivity logs a transient, recoverable startup ping-retry failure (LogLevel.Error, event MembershipJoiningPreconditionFailure) during a newly-joining silo's pre-active connectivity check. This is pre-existing MembershipAgent behavior, unrelated to recent PRs dotnet#11431/dotnet#11447/dotnet#11426/dotnet#10187/dotnet#10772: each retriable attempt logs at error level even when a subsequent retry succeeds and the connectivity-validation loop breaks cleanly. Only exhausted retries (MaxJoinAttemptTime elapsed) throw and fail silo startup, which would already fail this test before reaching its final assertion. Add a narrow filter, consistent with the existing IsExpectedClientRoutingTableCancellation/IsExpectedDirectoryPartitionRejection filters, that excludes only this specific recovered-retry log line and surfaces the count/content of any filtered retries in test output for visibility. Fixes dotnet#11444

Problem
Both #11446 and #11434 retain a system RPC timeout immediately after an in-memory silo connection closes during startup. The metadata failure also records a connection rejection and a failed preamble write; the Cosmos failure records the same startup connection-close pattern before
GetSiloManifestHashtimes out.SiloConnectionpublishes itself toConnectionManagerfrom the peer-preamble read continuation. That continuation can run before the local preamble write is even queued, allowing concurrent senders to enqueue framed messages ahead of the protocol preamble.The cancellation audit also found that TLS connector/listener tokens stopped at the underlying transport's creation or acceptance. Authentication used only its own handshake timeout. Controlled client-write, client-read, and server-read cases all remained pending after establishment cancellation when that timeout was infinite.
Solution
Publish the connection after both preamble operations complete: peer identity and cluster validation, and the local preamble write. Preserve the existing connection-establishment admission and shutdown paths.
Flow the outbound shutdown/deadline token and inbound listener shutdown token through connection runners and protocol initialization. Check cancellation before readiness publication. Pass connector/listener tokens into TLS startup and link authentication to establishment cancellation, underlying transport closure, and the existing handshake timeout. Keep authentication cancellation scoped to initialization; established connections retain their existing lifetime ownership.
Honor pre-canceled TCP, Unix, and in-memory listener binds before allocating or registering an endpoint. Schedule canceled startup attempts so they can complete accepted requests, and drain cleanup independently of the canceled establishment token before releasing buffers and transport resources.
Add deterministic inbound/outbound regressions for preamble ordering, failed writes, and cancellation before publication. Cover token identity, pre-canceled startup, established-connection lifetime, client/server TLS cancellation in read/write stages, queued-request completion, handshake-source detachment, and canceled binding resource ownership. Document the phase and ownership guarantees.
Extend the TLS end-to-end matrix to TCP, Unix-domain sockets, and in-memory transports, exercising all seven certificate and authentication-mode configurations over each transport.
Rationale
The controlled regression reproduces premature publication in both directions against the original implementation. Gating publication at the handshake boundary repairs the transport invariant shared by manifest and metadata retrieval while retaining their RPC deadlines, retry behavior, and exact convergence assertions.
The additional audit traces client, gateway, socket, Unix, in-memory, stream, and TLS paths. Client connections are published after initialization; gateways register clients after both preambles; TLS starts Orleans request processing after authentication. The silo publication repair applies to all these underlying transports through the shared
SiloConnectionimplementation. No separate analogous publication defect was found.Establishment cancellation now reaches the TLS handshake and protocol readiness boundary. Managers and listeners continue closing owned transports to interrupt pending preamble operations, preserving completion of accepted work and buffer ownership during cleanup.
The retained logs establish a common transport-failure signature, but do not capture the actual byte ordering of the historical failed connections. These investigations remain open for recurrence validation.
Addresses #11446 and #11434.
Microsoft Reviewers: Open in CodeFlow