Skip to content

fix: forward cancellation tokens in Cosmos grain storage - #11412

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-forward-cosmos-cancellation
Oct 6, 2026
Merged

ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rb-fix-forward-cosmos-cancellation

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Cosmos grain storage currently implements only the tokenless IGrainStorage methods, 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, propagate OperationCanceledException unchanged and preserve the local state and metadata. SDK cancellation with an active caller token retains the existing error logging and WrappedException behavior, 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

Copilot AI balanced review requested due to automatic review settings October 6, 2026 21:56

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.

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.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 22: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.

Copilot review overview

🟢 Approval recommended

No blocking issues were identified in cancellation handling, backward compatibility, or regression coverage; tests were not executed.

Review effort: Balanced
Findings: None

Copilot AI balanced review requested due to automatic review settings October 6, 2026 22:38

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.

Copilot review overview

🟢 Approval recommended

Static review found no blocking issues in cancellation handling or compatibility; regression tests were not executed.

Review effort: Balanced
Findings: None

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 83.19% (117,708 / 141,489) 83.21% (117,720 / 141,473) -0.0179 pp
Branches 72.70% (34,852 / 47,940) 72.72% (34,858 / 47,934) -0.0216 pp

Report-only conclusion: regressed.

The current-main baseline is commit b084e035b8 and uses the same reviewed coverage matrix.

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

@ReubenBond
ReubenBond merged commit 939f7f8 into dotnet:main Oct 6, 2026
92 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-forward-cosmos-cancellation branch October 6, 2026 23:16
ReubenBond added a commit to ReubenBond/orleans that referenced this pull request Oct 22, 2026
ReubenBond added a commit that referenced this pull request Oct 23, 2026
(cherry picked from commit 939f7f8)

Upstream-PR: #11412
Upstream-Commit: 939f7f8
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