Skip to content

fix(testing): wait for async cleanup timer rearm - #10348

Open
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:reubenbond-stabilize-async-cleanup
Open

fix(testing): wait for async cleanup timer rearm#10348
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:reubenbond-stabilize-async-cleanup

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 7, 2026

Copy link
Copy Markdown
Member

The async enumerable cleanup diagnostic is emitted before the grain timer callback returns and rearms its one-shot timer. A second fake-time advance could therefore occur too early and miss the next cleanup tick.

Track successful timer rearm operations in the test fake time provider and wait for the specific cleanup timer to rearm after each observed cleanup. This keeps the existing slow-consumer eviction assertions deterministic without changing production behavior or extending timeouts.

Copilot AI review requested due to automatic review settings August 7, 2026 00:53

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 fixes test flakiness in AsyncEnumerableGrainCallTests by making fake-time advances wait for the async-enumerator cleanup timer to be re-armed after each observed cleanup, ensuring subsequent fake-time advances don’t occur before the next one-shot timer tick is scheduled.

Changes:

  • Track timer Change(...) calls in a TrackingFakeTimeProvider wrapper around FakeTimeProvider timers.
  • Capture the async-enumerable cleanup timer instance via diagnostics and expose it on the test listener.
  • After each cleanup observation, wait for the corresponding timer re-arm (ChangeCount increment) before advancing time again.
Show a summary per file
File Description
test/Orleans.DefaultCluster.Tests/AsyncEnumerableGrainCallTests.cs Adds fake-time timer rearm tracking and updates the async-enumerable cleanup advancement logic to wait for rearm deterministically.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +731 to +739
private readonly ConcurrentDictionary<object, TrackingTimer> _timers = new(ReferenceEqualityComparer.Instance);

public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
var timer = new TrackingTimer(base.CreateTimer(callback, state, dueTime, period));
if (state is not null)
{
_timers[state] = timer;
}
Track the cleanup grain timer's successful Change calls in the fake time provider and wait for rearm after each cleanup notification. This prevents a subsequent fake-time advance from racing the timer callback while preserving the eviction assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 01:12
@ReubenBond
ReubenBond force-pushed the reubenbond-stabilize-async-cleanup branch from 4c085dd to a97af5e Compare August 7, 2026 01:12

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's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

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