feat(directory): add cancellation-aware operations - #10339
Merged
ReubenBond merged 1 commit intoAug 4, 2026
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
CancellationTokenoverloads toIGrainDirectory(with default cancelable waits) and updates the public API surface. - Propagates cancellation through
GrainLocatorintoCachedGrainLocator, 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
This was referenced Aug 28, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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