Skip to content

fix: preserve cached TestProbe refs across recovery#745

Merged
Aaronontheweb merged 1 commit into
akkadotnet:devfrom
Aaronontheweb:fix/stable-testprobe-recovery
May 18, 2026
Merged

fix: preserve cached TestProbe refs across recovery#745
Aaronontheweb merged 1 commit into
akkadotnet:devfrom
Aaronontheweb:fix/stable-testprobe-recovery

Conversation

@Aaronontheweb
Copy link
Copy Markdown
Member

Summary

  • register TestProbe in the actor registry via a stable forwarding actor instead of the ephemeral underlying TestActor
  • retarget that stable ref synchronously when EnsureTestActorAliveAsync recreates the underlying TestActor
  • add a deterministic regression test proving startup-cached IRequiredActor<TestProbe>.ActorRef values still deliver after recovery

Why

The merged host-startup race fix repairs direct TestActor use, but actors created during WithActors can cache IRequiredActor<TestProbe>.ActorRef before recovery runs. Re-registering a new raw TestActor in ActorRegistry does not update those cached refs.

This follow-up closes that hole by giving TestProbe a stable registered identity whose target can be swapped safely after recovery.

Testing

  • dotnet build src/Akka.Hosting.TestKit.Tests/Akka.Hosting.TestKit.Tests.csproj -c Release
  • dotnet test src/Akka.Hosting.TestKit.Tests/Akka.Hosting.TestKit.Tests.csproj -c Release --no-build --framework net8.0 --filter "Akka.Hosting.TestKit.Tests.TestActorRecoveryRegistrySpec.Cached_required_TestProbe_reference_should_survive_TestActor_recovery|Akka.Hosting.TestKit.Tests.TestActorStartupDeadlockSpec.parallel_host_start_should_not_deadlock"

@Aaronontheweb Aaronontheweb merged commit ab5c80d into akkadotnet:dev May 18, 2026
2 checks passed
@Aaronontheweb Aaronontheweb deleted the fix/stable-testprobe-recovery branch May 18, 2026 22:10
@Aaronontheweb Aaronontheweb mentioned this pull request May 18, 2026
This was referenced May 19, 2026
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.

1 participant