Skip to content

fix(persistence): flow grain storage cancellation tokens - #10641

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-grain-storage-cancellation
Aug 18, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-grain-storage-cancellation

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

Grain persistence exposes cancellation-aware IStorage operations, but StateStorageBridge previously invoked only the cancellation-free IGrainStorage methods. Storage providers therefore could not receive the caller's cancellation token.

This change adds cancellation-token overloads to IGrainStorage and forwards tokens through StateStorageBridge. Parameterless operations pass CancellationToken.None, and caller-requested cancellation propagates without storage-failure wrapping.

The new interface methods use default implementations which delegate to the existing overloads, preserving compatibility for storage providers while allowing providers to opt into backend cancellation. The provider-authoring documentation, public API surface, XML references, and focused cancellation coverage are updated accordingly.

Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 17, 2026 22:54

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 pull request updates Orleans persistence so that caller cancellation tokens are propagated end-to-end from IStorage operations through StateStorageBridge into IGrainStorage, enabling storage providers to observe and act on cancellation.

Changes:

  • Added CancellationToken overloads to IGrainStorage using default interface implementations to preserve compatibility with existing providers.
  • Updated StateStorageBridge to forward cancellation tokens to storage providers and to avoid wrapping caller-requested cancellations.
  • Updated docs/API surface and added focused tests verifying overload delegation and token propagation behavior.
Show a summary per file
File Description
test/Orleans.Core.Tests/Storage/StateStorageBridgeCancellationTests.cs Adds tests validating IGrainStorage default-overload delegation and StateStorageBridge token propagation behavior.
src/Orleans.Runtime/Storage/StateStorageBridge.cs Forwards cancellation tokens from IStorage calls to IGrainStorage and preserves caller-requested cancellation semantics.
src/Orleans.Persistence.Memory/Storage/MemoryStorageWithLatency.cs Updates XML doc <see cref> targets to disambiguate after new overloads were introduced.
src/Orleans.Core/Providers/IGrainStorage.cs Introduces cancellation-token overloads with default implementations delegating to legacy methods for compatibility.
src/Azure/Orleans.Persistence.AzureStorage/Providers/Storage/AzureTableStorage.cs Updates XML doc <see cref> targets to the now-ambiguous method signatures.
src/Azure/Orleans.Persistence.AzureStorage/Providers/Storage/AzureBlobStorageOptions.cs Updates XML doc reference to the disambiguated ClearStateAsync overload.
src/Azure/Orleans.Persistence.AzureStorage/Providers/Storage/AzureBlobStorage.cs Updates XML doc <see cref> targets to disambiguate after overload additions.
src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Updates XML doc <see cref> targets to the now-ambiguous method signatures.
src/api/Orleans.Core/Orleans.Core.cs Updates generated public API surface to include the new IGrainStorage overloads.
src/AdoNet/Orleans.Persistence.AdoNet/Storage/Provider/AdoNetGrainStorage.cs Updates XML doc <see cref> targets to disambiguate after overload additions.
docs/site/src/content/docs/tutorials-and-samples/custom-grain-storage.md Documents the new cancellation-token overloads and the token-flow behavior.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Comment on lines +11 to +13
using Orleans.Serialization.Activators;
using Orleans.Serialization.Serializers;
using Orleans.Storage;
@ReubenBond
ReubenBond marked this pull request as ready for review August 18, 2026 00:05
@ReubenBond
ReubenBond merged commit ca9552b into dotnet:main Aug 18, 2026
73 checks passed
@ReubenBond
ReubenBond deleted the rb-grain-storage-cancellation branch August 18, 2026 00:06
This was referenced Aug 28, 2026
This was referenced Sep 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 17, 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