Fix TestActor initialization race in parallel test startup#8023
Merged
Arkatufus merged 11 commits intoJan 27, 2026
Conversation
Add synchronization mechanism to ensure TestActor.PreStart() completes before CreateInitialTestActor returns. This fixes a race condition where the TestActor's Create message hasn't been processed yet when another actor (like PingerActor) tries to send messages to it. Changes: - InternalTestActor: Add optional ManualResetEventSlim parameter that gets signaled in PreStart() when actor initialization is complete - TestKitBase.CreateInitialTestActor: Wait for the init signal before returning, ensuring the actor is fully ready This provides a deterministic fix for ParallelTestActorDeadlockSpec failures that were occurring under high parallelism on Windows CI.
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this pull request
Jan 25, 2026
Wrapped three tests in AssertAllStagesStoppedAsync to ensure proper cleanup of stream stages before tests complete: - QueueSource_should_emit_received_message_to_the_stream - QueueSource_should_reject_elements_when_backpressuring_with_maxBuffer_0 - QueueSource_should_buffer_when_needed (the failing test from PR akkadotnet#8023) The failure "Failed to stop [QueueSourceSpec-920] within [00:00:05]" occurred because stream stages weren't properly stopped when tests ended with just sub.Cancel() without waiting for cleanup.
2 tasks
Aaronontheweb
added a commit
that referenced
this pull request
Jan 25, 2026
Wrapped three tests in AssertAllStagesStoppedAsync to ensure proper cleanup of stream stages before tests complete: - QueueSource_should_emit_received_message_to_the_stream - QueueSource_should_reject_elements_when_backpressuring_with_maxBuffer_0 - QueueSource_should_buffer_when_needed (the failing test from PR #8023) The failure "Failed to stop [QueueSourceSpec-920] within [00:00:05]" occurred because stream stages weren't properly stopped when tests ended with just sub.Cancel() without waiting for cleanup.
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this pull request
Jan 26, 2026
1. AtLeastOnceDeliveryReceiveActorSpec.PersistentReceive_must_warn_about_unconfirmed_messages - Extended ReceiveWhileAsync timeout from 3s to 5s - Warning is sent after 3 redeliveries at 500ms intervals (1.5s min) - Extra buffer for CI scheduling delays 2. ReplicatorSpecs.Bugfix_Duplicate_Publish - Changed from Within(5s) block with default 3s ExpectMsg timeout - Now uses explicit 5s timeout per probe ExpectMsg call - Cluster gossip can be slow on busy CI 3. UnhandledMessageEventFilterTests.Unhandled_message_should_produce_info_message - Made deterministic by subscribing to UnhandledMessage events - Wait for UnhandledMessage to confirm message was processed - Guarantees Info log has been published before filter checks
2 tasks
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this pull request
Jan 26, 2026
1. AtLeastOnceDeliveryReceiveActorSpec.PersistentReceive_must_warn_about_unconfirmed_messages - Extended ReceiveWhileAsync timeout from 3s to 5s - Warning is sent after 3 redeliveries at 500ms intervals (1.5s min) - Extra buffer for CI scheduling delays 2. ReplicatorSpecs.Bugfix_Duplicate_Publish - Converted to async TestKit methods (ExpectMsgAsync, ExpectNoMsgAsync) - Added explicit 5s timeout for cluster gossip propagation - Removed synchronous ExpectMsg calls 3. UnhandledMessageEventFilterTests.Unhandled_message_should_produce_info_message - Made deterministic by subscribing to UnhandledMessage events - Wait for UnhandledMessage to confirm message was processed - Guarantees Info log has been published before filter checks
Aaronontheweb
added a commit
that referenced
this pull request
Jan 26, 2026
1. AtLeastOnceDeliveryReceiveActorSpec.PersistentReceive_must_warn_about_unconfirmed_messages - Extended ReceiveWhileAsync timeout from 3s to 5s - Warning is sent after 3 redeliveries at 500ms intervals (1.5s min) - Extra buffer for CI scheduling delays 2. ReplicatorSpecs.Bugfix_Duplicate_Publish - Converted to async TestKit methods (ExpectMsgAsync, ExpectNoMsgAsync) - Added explicit 5s timeout for cluster gossip propagation - Removed synchronous ExpectMsg calls 3. UnhandledMessageEventFilterTests.Unhandled_message_should_produce_info_message - Made deterministic by subscribing to UnhandledMessage events - Wait for UnhandledMessage to confirm message was processed - Guarantees Info log has been published before filter checks
4 tasks
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this pull request
Feb 9, 2026
…t#8023) Add synchronization mechanism to ensure TestActor.PreStart() completes before CreateInitialTestActor returns. This fixes a race condition where the TestActor's Create message hasn't been processed yet when another actor (like PingerActor) tries to send messages to it. Changes: - InternalTestActor: Add optional ManualResetEventSlim parameter that gets signaled in PreStart() when actor initialization is complete - TestKitBase.CreateInitialTestActor: Wait for the init signal before returning, ensuring the actor is fully ready This provides a deterministic fix for ParallelTestActorDeadlockSpec failures that were occurring under high parallelism on Windows CI.
3 tasks
Aaronontheweb
added a commit
that referenced
this pull request
Feb 9, 2026
Add synchronization mechanism to ensure TestActor.PreStart() completes before CreateInitialTestActor returns. This fixes a race condition where the TestActor's Create message hasn't been processed yet when another actor (like PingerActor) tries to send messages to it. Changes: - InternalTestActor: Add optional ManualResetEventSlim parameter that gets signaled in PreStart() when actor initialization is complete - TestKitBase.CreateInitialTestActor: Wait for the init signal before returning, ensuring the actor is fully ready This provides a deterministic fix for ParallelTestActorDeadlockSpec failures that were occurring under high parallelism on Windows CI.
This was referenced May 21, 2026
Open
Open
Closed
Open
Open
This was referenced Jun 1, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
TestActor.PreStart()completes beforeCreateInitialTestActorreturnsCreatemessage hasn't been processed yet when another actor tries to send messages to itChanges
ManualResetEventSlimparameter that gets signaled inPreStart()when actor initialization is completeRoot Cause
When running multiple TestKits in parallel (as in
ParallelTestActorDeadlockSpec), there was a race between:Createmessage being processed (which triggersPreStart())The
ManualResetEventSlimsynchronization ensures step 2 completes beforeCreateInitialTestActorreturns.Test plan