fix concurrency issues in ActivationCollector#9740
Merged
DeagleGross merged 2 commits intomainfrom Nov 3, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a concurrency issue in the ActivationCollector.DeactivateInDueTimeOrder method by creating a snapshot of the buckets dictionary before iteration, preventing collection modification exceptions during enumeration.
- Refactored test code to use a shared
PrepareActivationhelper method - Added a comprehensive concurrency test (
DeactivateInDueTimeOrder_ConcurrentModification_ShouldNotThrow) - Fixed the race condition by taking a snapshot of
bucketsbefore ordering and iteration
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Orleans.Runtime/Catalog/ActivationCollector.cs |
Fixed concurrency issue by snapshotting the buckets dictionary before ordering |
test/NonSilo.Tests/Runtime/ActivationCollectorTests.cs |
Refactored existing test to use helper methods and added comprehensive concurrency test |
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.
I've managed to write a test, which consistenly reproduces the following error when trying to
DeactivateInDueTimeOrder:Then made a fix to snapshot bucket collection before performing
.OrderBy()to not fall into this trap. Fix done by Copilot in #9704 is roughly what we need, but test was not reproducing correctly, so I had to manually validate and adjust it.Fixes #9686
Microsoft Reviewers: Open in CodeFlow