Align all membership providers' CleanupDefunctSiloEntries to remove non-Active stale entries#9972
Align all membership providers' CleanupDefunctSiloEntries to remove non-Active stale entries#9972
Conversation
|
@copilot note that we have an implementation of an in-memory membership table cleanup here: src\Orleans.TestingHost\InProcess\InProcessMembershipTable.cs. You can take inspiration from that. |
Fixed |
Done in commit 493f3b1. Updated all providers to remove non-Active stale entries:
The other providers (Redis, Cassandra, AzureStorage, Consul, DynamoDB, AdoNet) were already using the correct non-Active predicate. |
|
@copilot do the new Cosmos and Zookeeper implementations materialize the whole silo list and then filter down to not active silos? Is there an elegant way to do filtering on the database side without needing to make any changes to the database schema/layout/indexes/etc.? |
Cosmos (commit e03465f): Yes, the previous version called ZooKeeper: ZooKeeper is a hierarchical KV store with no query capability — you list child node names, then fetch each node's data individually. There's no way to push predicates to the server. Full materialization is inherent to its architecture, so the current implementation is already optimal. |
|
@copilot I don't think that strictly If the above is correct then let's go with doing just the Status filtering in Cosmos (since that's indexed already) and then keep the date filtering all in C# to preserve the desired behavior. |
Fixed in commit 2d0523f. The Cosmos query now only pushes |
| foreach (var (entry, _) in rows) | ||
| { | ||
| if (entry.Status != SiloStatus.Active | ||
| && new DateTime(Math.Max(entry.IAmAliveTime.Ticks, entry.StartTime.Ticks), DateTimeKind.Utc) < beforeDate) |
There was a problem hiding this comment.
@copilot instead of creating a new datetime here, compare the max ticks to the beforeDate.Ticks.
Make the same update to the Cosmos implementation.
There was a problem hiding this comment.
Done in commit 0d6d77c. Both ZooKeeper and Cosmos now use Math.Max(...Ticks) < beforeDate.Ticks directly.
Fix InMemoryMembershipTable.CleanupDefunctSiloEntries to remove all non-Active old entries instead of only Dead entries, consistent with other provider implementations (Cassandra, Azure, etc.). Add unit tests for the fixed behavior in InMemoryMembershipTableTests. Co-authored-by: rkargMsft <164392675+rkargMsft@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/orleans/sessions/28c01159-31b4-4141-841b-f5f1aec83732
Apply the same non-Active predicate to InProcessMembershipTable used by the in-process test cluster, for consistency. Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/orleans/sessions/8e740b40-c62d-4e85-8aac-9c8a56f39bc7
…ve stale entries - CosmosMembershipTable: remove all non-Active stale entries (was only Dead), using proper Math.Max(IAmAliveTime, StartTime) timestamp check - ZooKeeperBasedMembershipTable: implement CleanupDefunctSiloEntries (was NotImplementedException) to delete non-Active stale entries Co-authored-by: rkargMsft <164392675+rkargMsft@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/orleans/sessions/cfa9474b-c8f1-4707-b13e-8ac1054679e7
… query Instead of fetching all silos and filtering in memory, build a server-side LINQ query that filters by status != Active and both date fields. The Status field is indexed; IAmAliveTime/StartTime are not indexed but the status filter reduces the result set without schema changes. Co-authored-by: rkargMsft <164392675+rkargMsft@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/orleans/sessions/55b130f3-7c14-4eac-bc1d-a808e43da0cb
…, keep date check in C# The Status field is indexed in Cosmos so filtering non-Active entries server-side is efficient. The date check uses Math.Max(IAmAliveTime, StartTime) semantics in C# to correctly handle cases where IAmAliveTime may be uninitialized (DateTime.MinValue). Co-authored-by: rkargMsft <164392675+rkargMsft@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/orleans/sessions/06efe6ea-ad61-43fd-ba3e-9e4f08a8752f
…ing new DateTime Co-authored-by: rkargMsft <164392675+rkargMsft@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/orleans/sessions/0d84e85c-6909-4b6e-8d16-0f2e6782c645
0d6d77c to
cb62440
Compare
InMemoryMembershipTable.CleanupDefunctSiloEntriesto remove all non-Active old entries (not just Dead entries)InProcessMembershipTable.CleanupDefunctSiloEntriesto use the same!= SiloStatus.Activepredicate for consistencyCleanupDefunctSiloEntriesinInMemoryMembershipTableTestsCosmosMembershipTable.CleanupDefunctSiloEntries— pushStatus != Activefilter server-side (indexed), then apply date check in C# usingMath.Max(IAmAliveTime.Ticks, StartTime.Ticks) < beforeDate.Ticksto preserve correct semantics whenIAmAliveTimeis uninitializedZooKeeperBasedMembershipTable.CleanupDefunctSiloEntries— wasNotImplementedException; deletes non-Activeentries usingMath.Max(IAmAliveTime.Ticks, StartTime.Ticks) < beforeDate.Ticksdate comparison (ZooKeeper has no query capability so full materialization is unavoidable)Original prompt
CleanupDefunctSiloEntriesfor development clustering #8256🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
Microsoft Reviewers: Open in CodeFlow