Initiate migration before IGrainManagementExtension.MigrateOnIdle completes#9758
Merged
ReubenBond merged 3 commits intodotnet:mainfrom Nov 10, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ErrorHandlingTimedMethodWithErrortest.Microsoft Reviewers: Open in CodeFlow