Repository navigation
fix(client): honor startup cancellation and release startup resources - #11604
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Startup cancellation can still hang on an in-flight gateway refresh, and the required-service lookup breaks observer-drain tests because their fixture does not register GatewayManager.
2 open issues
What changed in this PR
Addresses #11585 by making Orleans client startup waits cancellation-aware and adding resource cleanup when startup is canceled before the client lifecycle begins.
Changes:
- Observe cancellation during manifest initialization, gateway discovery, and retry decisions.
- Preserve connection cancellation exceptions and clean up partially started client resources.
- Add regression tests using explicit startup-phase barriers and bounded cleanup assertions.
| File | Description |
|---|---|
test/Orleans.Runtime.Tests/ClientConnectionTests/ClusterClientTests.cs |
Adds cancellation and connection-cleanup regression tests. |
src/Orleans.Core/Runtime/OutsideRuntimeClient.cs |
Adds canceled-start cleanup and cancellation-aware retry handling. |
src/Orleans.Core/Messaging/GatewayManager.cs |
Makes gateway initialization and discovery waits cancelable. |
src/Orleans.Core/Messaging/ClientMessageCenter.cs |
Preserves cancellation exceptions during initial connection establishment. |
src/Orleans.Core/Manifest/ClientClusterManifestProvider.cs |
Accepts a cancellation token for the initial manifest wait. |
Review effort: Balanced
877a9bd to
496bbbe
Compare
Code coverage
Report-only conclusion: mixed. 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 |


Fixes #11585.
Client startup now cancels initialization work instead of only cancelling its wait. Manifest initialization cancels and joins its owned background run before returning
OperationCanceledException, propagates initialization failures, and keeps subsequent refreshes tied to client lifetime after startup succeeds. The runtime closes pending and established connections and stops callback/gateway timers when startup is cancelled.Gateway discovery uses additive
InitializeGatewayListProviderAsync(CancellationToken)andGetGatewaysAsync(CancellationToken)APIs. Built-in providers pass cancellation through their existing storage/SDK seams, including paginated reads and background gateway refreshes. Owned Cassandra sessions created during cancelled initialization are released; shared/borrowed clients and sessions retain their existing ownership.Backward compatibility: all tokenless gateway methods and existing public storage-helper signatures remain available, with no new obsoletion. Default interface implementations preserve legacy provider dispatch, bound legacy waits, and observe eventual completion. Generated public API changes are additive; normal Release package validation against 10.4.0 passes without new compatibility suppressions.
Manifest RPC cancellation signals the runtime while independently bounding the provider's local wait, preserving application cancellation-acknowledgement policy and runtime ownership of RPC callbacks. Deterministic regressions cover pre-cancelled/in-flight/completed initialization, owned-run joining, acknowledgement policy, legacy-provider compatibility, SDK token forwarding, pagination, and resource ownership.
Microsoft Reviewers: Open in CodeFlow