Skip to content

fix(reminders): prevent ticks after unregister - #10296

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:reubenbond-fix-reminder-quiescence
Jul 22, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:reubenbond-fix-reminder-quiescence

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Azure Table reminder refreshes can complete with a stale snapshot after a reminder has been unregistered. Removing the local entry immediately allowed that stale row to recreate the reminder and deliver another tick after quiescence was reported.

Retain stopped reminders as sequence-stamped tombstones until a newer refresh confirms deletion. Unregisters without a local entry now record an identity tombstone as well, and successful re-registration replaces the stopped entry so immediate stop/restart remains supported.

Microsoft Reviewers: Open in CodeFlow

Keep stopped reminders and absent-local deletion markers sequence-stamped until a newer table refresh confirms removal, preventing stale reads from restarting deleted reminders.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3e1201f4-2286-4cd5-bb60-3690810a4810
Copilot AI review requested due to automatic review settings July 22, 2026 00:39
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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 addresses a race where reminder table refresh results can be stale relative to an unregister operation, allowing a previously unregistered reminder to be recreated locally and fire again after quiescence was reported. It does so by retaining stopped reminders/tombstones with sequence stamps until a newer refresh confirms the deletion, while still allowing immediate stop/restart.

Changes:

  • Retain unregistered reminders locally as sequence-stamped stopped entries (and add identity tombstones when no local entry exists) to suppress stale table refresh results.
  • Purge tombstones on newer refresh confirmation and on range changes; clear tombstones on successful re-registration.
  • Add a regression test covering stop/restart behavior before the removed reminder is purged.
Show a summary per file
File Description
test/Orleans.Reminders.Tests/TimerTests/ReminderTests_TableGrain.cs Adds a test for restarting a reminder after unregister but before purge.
src/Orleans.Reminders/ReminderService/LocalReminderService.cs Implements tombstone/stopped-entry tracking and refresh suppression logic to avoid resurrecting reminders from stale reads.

Copilot's findings

Comments suppressed due to low confidence (1)

src/Orleans.Reminders/ReminderService/LocalReminderService.cs:378

  • localReminders is iterated and mutated in the same loop. If any reminder is out-of-range, localReminders.Remove(...) during foreach (var r in localReminders) will throw InvalidOperationException (collection modified). The new tombstone loop correctly uses Keys.ToArray(), so the reminders loop should follow the same safe pattern.
                removedReminderTasks.Add(r.Value.StopAsync(ReminderEvents.LocalReminderStopReason.RemovedFromRange));
                localReminders.Remove(r.Key);
            }

            foreach (var key in localReminderTombstones.Keys.ToArray())
  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread test/Orleans.Reminders.Tests/TimerTests/ReminderTests_TableGrain.cs
Comment thread src/Orleans.Reminders/ReminderService/LocalReminderService.cs
@ReubenBond ReubenBond changed the title Fix reminder quiescence after unregister fix(reminders): prevent ticks after unregister Jul 22, 2026
@ReubenBond
ReubenBond merged commit 35e5381 into dotnet:main Jul 22, 2026
853 of 861 checks passed
@ReubenBond
ReubenBond deleted the reubenbond-fix-reminder-quiescence branch July 22, 2026 13:59
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 22, 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