Repository navigation
fix: forward cancellation tokens in Cosmos grain storage - #11412
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Static review found no blocking issues in cancellation handling, compatibility, or regression coverage; tests were not executed.
Review effort: Balanced
Findings: None
What changed in this PR
Adds cancellation support to Orleans’ Cosmos grain-storage provider while preserving existing tokenless APIs.
Changes:
- Forward caller tokens through Cosmos requests and throttling retry waits.
- Preserve cancellation exceptions and legacy executor compatibility.
- Add regression coverage, documentation, and generated API updates.
| File | Description |
|---|---|
| test/Extensions/Orleans.Cosmos.Tests/CosmosGrainStorageCancellationTests.cs | Tests token forwarding, cancellation, state preservation, and compatibility. |
| src/Azure/Shared/Cosmos/CosmosOptions.cs | Adds persistence-only cancellation support to operation executors. |
| src/Azure/Orleans.Persistence.Cosmos/README.md | Documents cancellation behavior. |
| src/Azure/Orleans.Persistence.Cosmos/CosmosGrainStorage.cs | Adds cancellation-aware storage overloads and forwards tokens. |
| src/api/Azure/Orleans.Persistence.Cosmos/Orleans.Persistence.Cosmos.cs | Records the new public overloads. |
💡 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: regressed. 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 |
(cherry picked from commit 939f7f8) Upstream-PR: dotnet#11412 Upstream-Commit: 939f7f8
Cosmos grain storage currently implements only the tokenless
IGrainStoragemethods, so cancellation from persistent state operations is dropped before Cosmos DB requests and throttling retry waits.Add cancellation-aware read, write, and clear overloads and preserve the existing entry points by delegating with
CancellationToken.None. Forward the caller token through every Cosmos CRUD branch, including clear's prerequisite read and create/replace paths. Check cancellation around the tokenless document-ID provider boundary. When the caller token is canceled, propagateOperationCanceledExceptionunchanged and preserve the local state and metadata. SDK cancellation with an active caller token retains the existing error logging andWrappedExceptionbehavior, including legacy tokenless calls.Add a backwards-compatible cancellation-aware operation-executor overload and cancel the default executor's throttling waits. The shared-source change is scoped to
ORLEANS_PERSISTENCE, preserving the clustering and reminders API surfaces.Include deterministic Cosmos grain-storage regression coverage for exact token identity, alternate ETag/clear branches, pre-cancellation, in-flight cancellation, document-ID cancellation, retry cancellation, and compatibility/error behavior. Regenerate the Cosmos persistence API surface.
Microsoft Reviewers: Open in CodeFlow