Skip to content

feat(directory): add cancellation-aware operations - #10339

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:reubenbond-directory-cancellation-api
Aug 4, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:reubenbond-directory-cancellation-api

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Grain directory callers cannot currently propagate cancellation into directory implementations, so activation shutdown can leave registration work running and stale registrations are replaced non-atomically.

Add backward-compatible cancellation overloads with default cancelable waits, implement linked shutdown/caller cancellation in the distributed directory, propagate activation cancellation through the locator stack, and conditionally replace stale registrations in one register operation.

Microsoft Reviewers: Open in CodeFlow

Add compatible cancellation overloads for grain directories, propagate activation cancellation through the locator stack, and atomically replace stale registrations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 4, 2026 20:06

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 adds cancellation-aware directory operations so callers (notably activation shutdown paths) can propagate cancellation into grain directory implementations, reducing lingering work during shutdown and improving stale registration replacement behavior in the locator stack.

Changes:

  • Adds backward-compatible CancellationToken overloads to IGrainDirectory (with default cancelable waits) and updates the public API surface.
  • Propagates cancellation through GrainLocator into CachedGrainLocator, and updates activation registration to pass cancellation directly.
  • Updates the distributed grain directory to link caller cancellation with shutdown cancellation, and adjusts tests for the new conditional replace behavior.
Show a summary per file
File Description
test/Orleans.Core.Tests/Directory/IGrainDirectoryTests.cs Adds coverage ensuring new cancellation overloads default to cancelable waits.
test/Orleans.Core.Tests/Directory/CachedGrainLocatorTests.cs Updates mocks/expectations for new cancellation overload usage and conditional replace registration flow.
src/Orleans.Runtime/GrainDirectory/GrainLocator.cs Adds cancellation support to registration flow and forwards to cached locator when applicable.
src/Orleans.Runtime/GrainDirectory/DistributedGrainDirectory.cs Introduces cancellation overloads and links caller cancellation with shutdown token.
src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs Propagates cancellation into directory register operations and switches to conditional replace semantics.
src/Orleans.Runtime/Catalog/ActivationData.cs Passes activation cancellation token into grain locator registration.
src/Orleans.Core.Abstractions/GrainDirectory/IGrainDirectory.cs Adds cancellation-token overloads as default interface methods for backward compatibility.
src/api/Orleans.Core.Abstractions/Orleans.Core.Abstractions.cs Updates generated API surface to include the new overloads.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 4

Comment thread test/Orleans.Core.Tests/Directory/IGrainDirectoryTests.cs
Comment thread src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs
Comment thread src/Orleans.Runtime/GrainDirectory/DistributedGrainDirectory.cs
Comment thread src/Orleans.Runtime/GrainDirectory/DistributedGrainDirectory.cs
@ReubenBond
ReubenBond merged commit 0e013d4 into dotnet:main Aug 4, 2026
65 of 67 checks passed
@ReubenBond
ReubenBond deleted the reubenbond-directory-cancellation-api branch August 4, 2026 22:19
This was referenced Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 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