Skip to content

fix(resilience): add grain placement resilience policies - #9819

Merged
ReubenBond merged 8 commits into
dotnet:mainfrom
ReubenBond:fix/connection-resilience/1
Aug 22, 2026
Merged

ReubenBond merged 8 commits into
dotnet:mainfrom
ReubenBond:fix/connection-resilience/1

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Nov 25, 2025 •

Copy link
Copy Markdown
Member
Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings November 25, 2025 22:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates the Polly resilience framework into Orleans' grain placement system to add retry and timeout capabilities for placement operations, making the system more robust against transient failures.

  • Adds Polly-based resilience pipeline with configurable retry and timeout policies for grain placement
  • Introduces three new configuration options in SiloMessagingOptions: PlacementTimeout, PlacementMaxRetries, and PlacementRetryBaseDelay
  • Refactors placement logic to execute through a resilience pipeline with message expiration checks

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Directory.Packages.props Adds Polly (8.5.2) and Polly.Extensions (8.6.4) package references
src/Orleans.Core/Orleans.Core.csproj Adds Polly package references to Orleans.Core
src/Orleans.Runtime/Orleans.Runtime.csproj Adds Polly.Extensions package reference to Orleans.Runtime
src/Orleans.Runtime/OrleansRuntimeResiliencePolicies.cs New file defining resilience policies with timeout and retry strategies for placement operations
src/Orleans.Runtime/Configuration/Options/SiloMessagingOptions.cs Adds three new configuration properties for placement resilience with defaults
src/Orleans.Runtime/Hosting/DefaultSiloServices.cs Registers Orleans runtime resilience policies during service configuration
src/Orleans.Runtime/Placement/PlacementService.cs Integrates resilience pipeline into placement workflow with message expiration checks and context struct to avoid allocations

Comment thread Directory.Packages.props Resolved
@ReubenBond
ReubenBond force-pushed the fix/connection-resilience/1 branch from d6580ef to d5457b0 Compare November 26, 2025 21:26
@ReubenBond ReubenBond changed the title [Resilience] Integrate Polly for grain placement resilience and add configuration options fix(resilience): add grain placement resilience policies May 29, 2026
Copilot AI review requested due to automatic review settings August 16, 2026 09:33
@ReubenBond
ReubenBond force-pushed the fix/connection-resilience/1 branch from d5457b0 to 8f643fa Compare August 16, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (1)

src/Orleans.Runtime/Placement/PlacementService.cs:556

  • This TimeoutException is treated as transient by the placement retry policy, so an already-expired message will be retried repeatedly with backoff. Use a non-retriable exception type for expired messages (e.g., OperationCanceledException) so the pipeline fails fast.
                if (firstMessage.IsExpired)
                {
                    LogMessageExpiredDuringPlacement(_logger, targetGrain);
                    throw new TimeoutException($"Message expired before placement could complete for grain {targetGrain}.");
                }
  • Files reviewed: 8/8 changed files
  • Comments generated: 5
  • Review effort level: Lite

Comment thread src/Orleans.Core/Orleans.Core.csproj Resolved
Copilot AI review requested due to automatic review settings August 16, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 16, 2026 10:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

test/Orleans.Core.Tests/Runtime/PlacementServiceTests.cs:103

  • This test name says "DoesNotRetry", but it only asserts that an expired message throws OperationCanceledException and does not verify retry behavior. Either rename the test to match the assertion or add an assertion/counter proving that no retries occurred.
        [Fact]
        public async Task GetOrPlaceActivationAsync_ExpiredMessage_DoesNotRetry()
        {
            var target = CreateTarget();

src/Orleans.Runtime/Configuration/Options/SiloMessagingOptions.cs:182

  • The XML docs for PlacementTimeout say the operation will fail with TimeoutException, but Polly's timeout strategy throws TimeoutRejectedException. This can mislead users troubleshooting placement timeouts.
        /// <remarks>
        /// This timeout applies to the entire placement operation including retries.
        /// If the timeout is exceeded, the placement operation will fail with a <see cref="TimeoutException"/>.
        /// </remarks>
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread Directory.Packages.props Resolved
Copilot AI review requested due to automatic review settings August 16, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

test/Orleans.Core.Tests/Runtime/PlacementServiceTests.cs:101

  • The test name says "DoesNotRetry", but the assertion only verifies that an expired message throws OperationCanceledException and does not validate retry behavior. Consider renaming the test (or add assertions which explicitly prove no retries occurred).
        public async Task GetOrPlaceActivationAsync_ExpiredMessage_DoesNotRetry()

src/Orleans.Runtime/Placement/PlacementService.cs:529

  • PlacementTarget requires a non-null Dictionary<string, object> for requestContextData, but Message.RequestContextData can legitimately be null (e.g., MessageFactory sets it to RequestContextExtensions.Export(...), which returns null when the request context is empty). As written, firstMessage.RequestContextData! can cause a NullReferenceException during normal placement.
                var target = new PlacementTarget(
                    firstMessage.TargetGrain,
                    firstMessage.RequestContextData!,
                    firstMessage.InterfaceType,
                    firstMessage.InterfaceVersion);
  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 21, 2026 19:02
@ReubenBond
ReubenBond force-pushed the fix/connection-resilience/1 branch from b94c603 to 7e3005f Compare August 21, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants