Repository navigation
fix(directory)!: expose immutable partition boundaries - #11425
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Invalid mappings can trigger a tight retry loop, and the generated public API surface is missing.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Makes distributed-directory partition boundary mapping configurable for rolling-upgrade compatibility.
Changes:
- Adds configurable and legacy partition-boundary mappings.
- Validates boundary result shape and wires options into directory membership.
- Adds compatibility tests and upgrade guidance.
| File | Description |
|---|---|
GrainDirectoryOptionsTests.cs |
Tests configured routing mappings. |
DirectoryMembershipSnapshotTests.cs |
Tests defaults, legacy behavior, and validation. |
CoreHostingExtensions.cs |
Injects configured boundary function. |
DirectoryMembershipSnapshot.cs |
Validates boundary results. |
DirectoryMembershipService.cs |
Rejects null boundary functions. |
GrainDirectoryOptions.cs |
Exposes boundary configuration and legacy helper. |
grain-directory.md |
Documents boundary configuration. |
upgrades.md |
Documents rolling-upgrade compatibility. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: current-main baseline stale. The newest successful coverage run tested 165acd0, not current main ad8cf7c. 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 |
fdb0a84 to
132c853
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It changes distributed routing identity and terminal failure behavior during mixed-version cluster operation.
0 open findings
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
BREAKING CHANGE: SiloAddress.GetUniformHashCodes(int) now returns ImmutableArray<uint> instead of uint[]. GetPartitionBoundaries uses the same immutable result type. Rebuild callers against the new signature.
There was a problem hiding this comment.
🟡 Changes recommended
The unresolved public return-type break is broader than and inconsistent with the advertised compatibility solution.
1 open finding
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Backport the immutable boundary delegate, configuration validation, failure propagation, tests, generated API and upgrade guidance. Preserve the shipped uint[] SiloAddress hash API and current partition defaults. Upstream-PR: dotnet#11425 Upstream-Commit: ad8cf7c
Backport the immutable boundary delegate, configuration validation, failure propagation, tests, generated API and upgrade guidance. Preserve the shipped uint[] SiloAddress hash API and current partition defaults. Upstream-PR: dotnet#11425 Upstream-Commit: ad8cf7c
(cherry picked from commit ad8cf7c) Upstream-PR: dotnet#11425 Upstream-Commit: ad8cf7c

Problem
Orleans 10.1's experimental distributed directory assigned partition numbers after sorting each silo's uniform hashes. #10047 changed that mapping to hash-generation order, and #10050 changed the default partition count from 30 to one. Restoring the count alone therefore leaves mixed-version silos addressing different partitions for the same ranges during registration and ownership transfer.
SiloAddress.GetUniformHashCodesalso exposed its cached mutable array, so a caller could change the shared hash order or values used by other directory and ring consumers.Solution
Return
ImmutableArray<uint>fromSiloAddress.GetUniformHashCodes. Transfer ownership of the freshly computed array into the immutable cache usingImmutableCollectionsMarshal.AsImmutableArray, preserving cached storage reuse without a defensive copy on each call.Expose
GrainDirectoryOptions.GetPartitionBoundariesas aFunc<SiloAddress, int, ImmutableArray<uint>>, using the existing boundary function by default. Applications upgrading an existing 10.1 distributed-directory cluster configure 30 partitions and supply a delegate which returns the cached hashes in sorted immutable order. The upgrade guide provides a compiled snippet, and the compatibility and hosted-routing tests exercise that exact source.Keep the corrected index-based range storage and the current single-partition and generated-order defaults. Invalid boundary results stop membership processing and surface an
OrleansConfigurationExceptionto readers and refresh calls, preserving the original cause. Document cluster-wide mapping stability during upgrades and rollback, and regenerate both affected API surfaces.Breaking change
The broader return-type change is intentional and explicitly approved:
SiloAddress.GetUniformHashCodes(int)changes fromuint[]toImmutableArray<uint>for every caller, including consumers outside the distributed directory. It is a source- and binary-breaking change. Rebuild callers against the new signature; useToArray()for a mutable buffer orSort()for an immutable sorted result.The package compatibility suppression records this approved break; it does not preserve compatibility for previously compiled consumers. It is scoped to this method in Microsoft.Orleans.Core.Abstractions for net8.0 and net10.0, and all other package validation remains enabled. Normal Release packing passes.
Rationale
An unconditional return to sorted numbering would disrupt clusters already running newer multi-partition configurations. The general-purpose immutable delegate exposes the existing internal extension point, while compatibility policy for the experimental release remains application-owned.
Replacing the existing hash getter establishes one immutable cache-ownership contract for every ring consumer, protecting the shared cache at its source. This broader approved break is preferable to a directory-only copy or a second immutable getter alongside the mutable-array API. Cached storage reuse and generation order remain unchanged.
Microsoft Reviewers: Open in CodeFlow