Skip to content

fix(runtime): synchronize version selector cache generations - #10597

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-version-selector-cache-generations
Aug 14, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-version-selector-cache-generations

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 14, 2026

Copy link
Copy Markdown
Member

Cached version selector results can otherwise be computed and retained across different cluster manifest and membership generations, allowing stale silo selections during topology changes.

This change synchronizes selector reads with both membership and manifest versions using a unified cache generation, refreshes results when either generation changes, and adds a membership-aligned GetSupportedSilos path.

The existing CacheInvalidated event is intentionally retained and raised after the generation advances because the current PlacementService still subscribes to it. The follow-up placement integration will remove that compatibility event.

Microsoft Reviewers: Open in CodeFlow

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

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 updates Orleans runtime grain-version selection caching to avoid returning stale silo selections across cluster topology/manifest changes by synchronizing cached reads against both cluster manifest and membership versions.

Changes:

  • Reworks CachedVersionSelectorManager caching to use a unified cache generation and adds a membership-aligned GetSupportedSilos(GrainType) method.
  • Updates/extends unit tests to validate cache refresh behavior across membership + manifest updates and manifest minor version changes.
Show a summary per file
File Description
test/Orleans.Core.Tests/Manifest/ClusterManifestProviderTests.cs Extends tests to cover membership-aligned version-selector cache refresh and manifest minor-version refresh behavior.
src/Orleans.Runtime/Versions/CachedVersionSelectorManager.cs Replaces concurrent cache with generation-validated cache reads, adds membership-aware supported-silo reads, and updates reset/invalidations behavior.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Suppressed comments (1)

src/Orleans.Runtime/Versions/CachedVersionSelectorManager.cs:95

  • This retry loop can also spin aggressively under transient manifest/membership/generation changes. Consider yielding/backing off between retries to prevent unnecessary CPU usage.
                lock (this.cacheLock)
                {
                    var current = ObserveCacheState();
                    if (current.Generation == state.Generation
                        && resultVersion == current.ManifestVersion
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread src/Orleans.Runtime/Versions/CachedVersionSelectorManager.cs
Comment thread src/Orleans.Runtime/Versions/CachedVersionSelectorManager.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e0958d7d-4e8a-4ea8-b38b-5eb05529c312
Copilot AI review requested due to automatic review settings August 14, 2026 18:39

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit 6b30413 into dotnet:main Aug 14, 2026
134 of 137 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-version-selector-cache-generations branch August 14, 2026 21:01
This was referenced Sep 3, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 14, 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