Skip to content

Initiate migration before IGrainManagementExtension.MigrateOnIdle completes#9758

Merged
ReubenBond merged 3 commits intodotnet:mainfrom
ReubenBond:fix/FailDehydrationTest
Nov 10, 2025
Merged

Initiate migration before IGrainManagementExtension.MigrateOnIdle completes#9758
ReubenBond merged 3 commits intodotnet:mainfrom
ReubenBond:fix/FailDehydrationTest

Conversation

@ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Nov 9, 2025

This PR attempts to fix test flakiness (and flakiness observed by callers) when remotely calling IGrainManagementExtension.MigrateOnIdle() on a grain by ensuring that migration has been initiated (and the activation is no longer valid) before the call completes.

This does not guarantee that a this.MigrateOnIdle() call from within a grain will prevent the grain from processing any future requests (i.e, it could still remain valid for a short period).

It also includes a drive-by fix for the timing-sensitive ErrorHandlingTimedMethodWithError test.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings November 9, 2025 22:17
Copy link
Contributor

Copilot AI left a comment

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 modernizes asynchronous code patterns by replacing blocking Thread.Sleep calls with proper async/await using Task.Delay, and improves the migration workflow to support async completion signaling.

  • Converted synchronous blocking methods to proper async/await patterns in ErrorGrain
  • Simplified test timing logic by removing complex stopwatch-based race conditions
  • Enhanced migration workflow to properly signal completion using TaskCompletionSource

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/Grains/TestInternalGrains/ErrorGrain.cs Converted LongMethod and LongMethodWithError from blocking Thread.Sleep to async Task.Delay; fixed UnobservedErrorDelayed to properly use async lambda with Task.Factory.StartNew
test/DefaultCluster.Tests/ErrorGrainTest.cs Simplified ErrorHandlingTimedMethodWithError test by removing timing-dependent assertions that caused race conditions
src/Orleans.Runtime/Catalog/ActivationData.cs Refactored migration workflow to support async completion signaling via TaskCompletionSource in MigrateOnIdle; changed DeactivateCore to private visibility

ReubenBond and others added 2 commits November 10, 2025 09:17
@ReubenBond ReubenBond added this pull request to the merge queue Nov 10, 2025
@ReubenBond ReubenBond removed this pull request from the merge queue due to a manual request Nov 10, 2025
@ReubenBond ReubenBond merged commit 2ed2dfb into dotnet:main Nov 10, 2025
29 checks passed
@ReubenBond ReubenBond deleted the fix/FailDehydrationTest branch November 10, 2025 21:19
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2025
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.

1 participant

Comments