Enable rolling upgrade from LocalGrainDirectory to DistributedGrainDirectory#9881
Draft
ReubenBond wants to merge 5 commits intodotnet:mainfrom
Draft
Enable rolling upgrade from LocalGrainDirectory to DistributedGrainDirectory#9881ReubenBond wants to merge 5 commits intodotnet:mainfrom
ReubenBond wants to merge 5 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables rolling upgrades from the legacy DHT-based LocalGrainDirectory to the new DistributedGrainDirectory. The change ensures that old silos using LocalGrainDirectory can communicate with new silos using DistributedGrainDirectory during a rolling upgrade.
Changes:
- Added
DelegatingRemoteGrainDirectorysystem targets to handle IRemoteGrainDirectory requests from old silos - Changed service registration to register DistributedGrainDirectory and DirectoryMembershipService on all silos by default
- Added test infrastructure option
UseTestClusterGrainDirectoryand comprehensive migration tests
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Orleans.Runtime/GrainDirectory/DelegatingRemoteGrainDirectory.cs | New system target that delegates IRemoteGrainDirectory calls from old silos to DistributedGrainDirectory |
| src/Orleans.Runtime/Hosting/CoreHostingExtensions.cs | Updated AddDistributedGrainDirectory to remove LocalGrainDirectory lifecycle participation and register delegating system targets |
| src/Orleans.Runtime/Hosting/DefaultSiloServices.cs | Changed to register DistributedGrainDirectory on all silos and moved IGrainLocator registration |
| src/Orleans.Runtime/GrainDirectory/LocalGrainDirectory.cs | Updated constructor to create LocalGrainDirectoryPartition directly instead of via DI |
| src/Orleans.Runtime/GrainDirectory/LocalGrainDirectoryPartition.cs | Changed constructor to accept ILogger instead of ILoggerFactory |
| src/Orleans.Runtime/GrainDirectory/GrainDirectoryHandoffManager.cs | Removed unused Factory dependency |
| src/Orleans.Runtime/GrainDirectory/GrainLocatorResolver.cs | Changed to use IGrainLocator instead of DhtGrainLocator directly |
| src/Orleans.Runtime/GrainDirectory/GrainDirectoryPartition.cs | Fixed indentation and changed logging level from Error to Warning for transient failures |
| src/Orleans.Runtime/GrainDirectory/DistributedGrainDirectory.cs | Made _localActivations readonly and reordered fields |
| src/Orleans.Runtime/GrainDirectory/CachedGrainLocator.cs | Sealed the class |
| src/Orleans.Runtime/Core/InternalGrainRuntime.cs | Removed ILocalGrainDirectory dependency |
| src/Orleans.Core/Configuration/ServiceCollectionExtensions.cs | Added TaggedServiceDescriptor to track and remove service registrations by implementation type |
| src/Orleans.TestingHost/InProcTestClusterOptions.cs | Added UseTestClusterGrainDirectory property |
| src/Orleans.TestingHost/InProcTestClusterBuilder.cs | Set UseTestClusterGrainDirectory default to true |
| src/Orleans.TestingHost/InProcTestCluster.cs | Added validation and conditional registration of test grain directory |
| test/TesterInternal/LocalGrainDirectoryPartitionTests.cs | Updated test to use NullLogger instead of LoggerFactory and renamed class |
| test/TesterInternal/GrainDirectory/GrainDirectoryMigrationTests.cs | New comprehensive test suite for rolling upgrade scenarios |
f514819 to
ab2801c
Compare
5d23709 to
d9036ea
Compare
auto-merge was automatically disabled
January 20, 2026 22:01
Pull request was converted to draft
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR enables basic support for rolling upgrades from the legacy DHT-based
LocalGrainDirectoryto theDistributedGrainDirectory(enabled by callingISiloBuilder.AddDistributedGrainDirectory()). When performing an upgrade, users must follow the procedure detailed under the 'Rolling Upgrade Path' header.There are caveats to this rolling uprade support. In particular, there will be inconsistency during the rollout: there can be duplicate activations created for a given grain, since different hosts have different ideas of what the correct directory for a given grain is. After the rollout is complete and all hosts are running the
DistributedGrainDirectory, there is no more chance for inconsistency and there will be no orphaned (unregistered) or duplicate activations.A different strategy could include attempts to reduce the chance for inconsistency during the rollout window. For now, that is not something I intend to pursue since it greatly increases complexity for dubious benefit.
Changes
DelegatingRemoteGrainDirectory- A system target that handlesIRemoteGrainDirectoryrequests from old silos still usingLocalGrainDirectory. This allows old silos to communicate with new silos during a rolling upgrade. It implements the same grain types (Constants.DirectoryServiceType, Constants.DirectoryCacheValidatorType) thatLocalGrainDirectoryuses.DistributedGrainDirectoryandDirectoryMembershipServiceare now registered on all silos by default (not just when explicitly enabled). This ensuresIGrainDirectoryClientis available for recovery queries during rolling upgrades. WhenAddDistributedGrainDirectory()is called:LocalGrainDirectorylifecycle participationIGrainLocatorfromDhtGrainLocatortoCachedGrainLocatorLocalGrainDirectoryPartitionfrom DI - It's now created directly byLocalGrainDirectoryinstead of being injected.UseTestClusterGrainDirectoryoption toInProcTestClusterOptionsfor testing.GrainDirectoryMigrationTests- Tests covering rolling upgrade scenarios.Rolling Upgrade Path
To take advantage of this new functionality, you will need to perform two complete rollouts. The first adds support for the new directory on all hosts. The second switches to it by default.
AddDistributedGrainDirectory()in your silo configuration.IRemoteGrainDirectorymessages to new silos, which are handled byDelegatingRemoteGrainDirectory.DistributedGrainDirectoryfor all directory operations.Fixes #9356