Skip to content

fix(membership): do not report a silo dead before it writes its entry - #11581

Closed
nightBaker wants to merge 1 commit into
dotnet:mainfrom
nightBaker:fix/joining-silo-self-dead-notification
Closed

nightBaker wants to merge 1 commit into
dotnet:mainfrom
nightBaker:fix/joining-silo-self-dead-notification

Conversation

@nightBaker

@nightBaker nightBaker commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A silo of a new cluster can report itself Dead to its own ISiloStatusListeners while it is still starting. ConsistentRingProvider and VirtualBucketsRingProvider treat a terminating status for the local silo as a local shutdown, set running = false, and never reset it. From then on the silo never routes a key to itself.

The sequence:

  1. MembershipTableManager starts with the initial view {self: Created} at MembershipVersion.MinValue (MembershipTableManager.cs#L81-L90).
  2. Its first read finds the table empty. An empty table at version (0, "0") maps to MinValue (MembershipTableSnapshot.cs#L51-L53), is not a successor, and is not published. The view stays {self: Created}.
  3. SiloStatusListenerManager starts at AfterRuntimeGrainServices, so its first view is that {self: Created} one. Listeners receive (self, Created).
  4. MembershipAgent.BecomeJoining (same stage) reads the table again. Another silo has inserted itself in the meantime, so the new view contains that silo but not this one. ProcessMembershipUpdate returns it unchanged because the previous local status is Created (MembershipTableManager.cs#L571-L575).
  5. SiloStatusListenerManager diffs the two views with ClusterMembershipSnapshot.CreateUpdate, which reports a removed entry as Dead (ClusterMembershipSnapshot.cs#L108-L115). Listeners receive (self, Dead).
  6. VirtualBucketsRingProvider.SiloStatusChangeNotification(self, Dead) calls Stop() (VirtualBucketsRingProvider.cs#L209-L216). ConsistentRingProvider does the same.

The silo then writes itself Joining and becomes Active normally. The local status notifications it observed are [Created, Dead, Joining, Active].

Impact

Reminders are the visible casualty. LocalReminderService.RegisterOrUpdateReminder only schedules a reminder locally when the receiving silo owns the key (LocalReminderService.cs#L256-L260, from #10612). An affected silo sends registrations for keys it owns to its ring successor. The successor only persists the row, and the owner loads it at its next RefreshReminderListPeriod, up to 5 minutes later.

Found while load-testing Fleans (a BPMN engine on Orleans 10.4) on a 6-silo cluster whose 3 reminder-hosting silos start together against a fresh table. 2 of the 3 lost the race at every cold start. About 12 % of timers fired late: p99 lag 252 s, against 0.94 s before the upgrade from 10.0.1. The ring exclusion probably happened on 10.0.1 too, but was invisible because the receiving silo started the timer.

Fix

In ProcessMembershipUpdate, when a new view lacks the local silo and the local silo is still Created, keep the local Created entry. The local silo has not written its entry, so its absence from the table says nothing about its status, and the view no longer shows the local entry as removed. Once the silo writes its entry, the table's entry replaces the preserved one. The existing handling of a missing local entry after the silo has joined is unchanged.

The fix is in the membership view rather than in the ring providers because every consumer that diffs consecutive views sees the bogus Dead, not only the rings. This includes IClusterMembershipService.MembershipUpdates subscribers.

Two existing tests asserted that the view omits the local silo while it is Created. They now assert that the local entry is still Created, which checks the same thing: the local status did not advance.

Test

MembershipTableManager_NewCluster_OtherSiloJoinsFirst_DoesNotReportLocalSiloDead drives the sequence above with InMemoryMembershipTable and a real SiloStatusListenerManager. It starts against an empty table, inserts another silo, and refreshes. It then asserts that the listener receives (self, Created) and (other, Joining) only. On main it fails with Unexpected notification: (S127.0.0.1:100:100, Dead).

I also checked the symptom on two and three localhost-clustered silos with startup delays that force the race. On main, the late silo ended with running = false in 3 of 3 runs. With this change, every silo stayed running = true across 5 runs.

Microsoft Reviewers: Open in CodeFlow

@nightBaker

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@nightBaker
nightBaker force-pushed the fix/joining-silo-self-dead-notification branch from a187ae1 to 9af81b0 Compare October 24, 2026 05:02
A silo which starts against an empty membership table keeps its initial
view, {self: Created}, because the empty read has version MinValue and is
not a successor. If another silo inserts itself before this silo writes
its own entry, the next read lacks the local silo. ProcessMembershipUpdate
published that view as-is, so observers which diff consecutive views
(SiloStatusListenerManager, ClusterMembershipSnapshot.CreateUpdate) saw the
local entry removed and reported (self, Dead). ConsistentRingProvider and
VirtualBucketsRingProvider treat that as a local shutdown and permanently
exclude the silo from its own ring.

Preserve the local Created entry when a view lacks it. The silo has not
written its entry, so its absence says nothing about its status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nightBaker

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@ReubenBond

Copy link
Copy Markdown
Member

@nightBaker, thank you for the thorough investigation, the startup-race reproduction, and this PR. Connecting the false local Dead notification to delayed reminders was particularly helpful.

We have chosen to address this with canonical membership views and separate local lifecycle status in #11588: #11588. That PR builds on your work, retains your original contribution in the commit history, and extends the regression scenario.

The key invariant is that every published membership view represents authoritative cluster state. Preserving an uncommitted local Created row breaks that invariant: startup cleanup of a predecessor can gossip the synthetic row before the new incarnation registers. A peer can then reject a same-version table refresh because the synthetic non-dead row disappears, preventing it from accepting newer heartbeat timestamps.

The replacement starts with an empty membership snapshot and keeps local Created status separately. Committed registration introduces the local row normally, so observers see no false removal. It also publishes the actual removal when a registered silo is pruned, derives local Dead status without manufacturing a snapshot entry, and reconciles delayed write completions under the existing publication lock.

This makes #11588 the replacement implementation for this issue rather than an additional fix to merge after this PR. Thanks again for finding the bug and providing such a clear explanation and reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants