Skip to content

fix(reminders): order topology reconciliation admission - #11118

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-dynamodb-reminder-flake
Sep 5, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-dynamodb-reminder-flake

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Problem

Reminder lifecycle topology stabilization enqueued an explicit refresh on every active silo after membership listeners had already processed the current version. That redundant provider work could stall at refresh admission or reconciliation under provider load, even though membership, manifests, and ring ownership had converged.

Replacing the refresh with a separate scheduler turn retained the same admission dependency. Publishing reconciliation generations only when scheduler callbacks executed also allowed queued refreshes and range changes to be observed in a different order from their scheduler execution order.

A topology change during reminder-service startup could additionally invalidate the initial range read before the service subscribed to ring notifications.

Solution

Subscribe the local reminder service to ring changes before its initial read and repeat the load whenever its range changes during the read, so startup readiness covers a stable current range.

Publish and enqueue every range change, explicit refresh, and periodic refresh through one ordered reconciliation-admission path. Generation publication and scheduler FIFO enqueue now occur atomically, and previous-generation waiters are signaled only after the new generation and its exact task are installed. The periodic timer waits outside the grain scheduler and queues the actual refresh turn through this path.

Topology stabilization waits for membership listener processing and then directly awaits the latest published reconciliation generation. It no longer creates unrelated provider work or depends on a separate scheduler no-op.

Add deterministic coverage for stable multi-silo startup, membership-triggered range reconciliation, and both refresh-before-range and range-before-refresh ordering.

Rationale

Membership processing synchronously queues the associated ring changes before publishing its processed version. Using the same admission path for every reconciliation operation preserves that causal order through scheduler execution, so the topology barrier awaits the work caused by the topology itself.

Fixes #11023

Related: #11016, #11108

Copilot AI lite review requested due to automatic review settings September 5, 2026 01:22

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.

Copilot review overview

🟡 Changes recommended

The new private protected access modifier on SubscribeToRangeChangeEvents prevents LocalReminderService (in a different assembly) from calling it, and the initial-load loop should drain queued range-change turns before deciding the range stayed stable.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity · 1 Medium severity

New issues introduced by this change (2)
Severity Finding
High severity src/​Orleans.Runtime/​Services/​GrainService.cs — SubscribeToRangeChangeEvents is declared private protected, which makes it inaccessible to…
Medium severity src/​Orleans.Reminders/​ReminderService/​LocalReminderService.cs — The initial-load retry loop only compares RangeSerialNumber before/after…
What changed in this PR

This PR updates Orleans reminder-service topology stabilization to avoid redundant provider refreshes in tests and to make reminder-service startup readiness robust against ring range changes during the initial load, addressing recent flaky timeout scenarios in reminder lifecycle tests.

Changes:

  • Removes the “all-silo explicit refresh” from ReminderTopologyStabilizer and instead uses a FIFO scheduler boundary plus the existing reconciliation-generation barrier.
  • Updates LocalReminderService startup to subscribe to ring changes before the initial read and to repeat the initial load when the owned range changes during the read.
  • Adds deterministic tests validating that stable topology does not cause extra provider reads and that joins wait behind the queued range-change turn and the subsequent provider read.
File Description
test/​Orleans.Testing.Reminders/​ReminderTopologyStabilizer.cs Removes redundant refresh and relies on scheduler/reconciliation boundaries for deterministic topology stabilization.
test/​Orleans.Reminders.Tests/​TimerTests/​LocalReminderServiceTests.cs Adds deterministic coverage for “no extra refresh” and “wait for membership range reconciliation” scenarios; updates fixture to use ReminderTestClock.
src/​Orleans.Runtime/​Services/​GrainService.cs Refactors ring subscription into a helper method used on status transitions.
src/​Orleans.Reminders/​ReminderService/​LocalReminderService.cs Subscribes to range changes before initial load and retries initial load when range changes during the read.

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

Copilot AI review requested due to automatic review settings September 5, 2026 03:15
@ReubenBond ReubenBond changed the title fix(testing): avoid redundant reminder topology refresh fix(reminders): order topology reconciliation admission Sep 5, 2026

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.

Copilot review overview

🔵 Needs a closer look

It changes core reminder reconciliation ordering and scheduler/admission behavior with subtle concurrency implications which merit final human validation.

Review tier: Lite
Findings: 1 High severity · 1 Medium severity

Pre-existing issues (2)
Severity Finding
High severity src/​Orleans.Runtime/​Services/​GrainService.cs — SubscribeToRangeChangeEvents is declared private protected, which makes it inaccessible to… View comment
Medium severity src/​Orleans.Reminders/​ReminderService/​LocalReminderService.cs — The initial-load retry loop only compares RangeSerialNumber before/after… View comment

@ReubenBond
ReubenBond merged commit 6905cb2 into dotnet:main Sep 5, 2026
67 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-dynamodb-reminder-flake branch September 5, 2026 05:16
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.

Flaky DynamoDB stale-owner reminder test times out after topology convergence

2 participants