Repository navigation
fix(resilience): add grain placement resilience policies - #9819
Conversation
There was a problem hiding this comment.
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, andPlacementRetryBaseDelay - 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 |
d6580ef to
d5457b0
Compare
d5457b0 to
8f643fa
Compare
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Orleans.Runtime/Placement/PlacementService.cs:556
- This
TimeoutExceptionis 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
There was a problem hiding this comment.
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
OperationCanceledExceptionand 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
PlacementTimeoutsay the operation will fail withTimeoutException, but Polly's timeout strategy throwsTimeoutRejectedException. 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
There was a problem hiding this comment.
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
OperationCanceledExceptionand 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
PlacementTargetrequires a non-nullDictionary<string, object>forrequestContextData, butMessage.RequestContextDatacan legitimately be null (e.g.,MessageFactorysets it toRequestContextExtensions.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
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
b94c603 to
7e3005f
Compare
Microsoft Reviewers: Open in CodeFlow