Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PORT #6366] set default PoolRouter SupervisorStrategy to Restart #6370

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/core/Akka.Tests/Actor/ActorTelemetrySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ await AwaitAssertAsync(async () =>
// assert that actor start count is still 10
Assert.Equal(12, telemetry.ActorCreated);

// bug due to https://github.com/akkadotnet/akka.net/issues/6295 - all routees and the router start each time
Assert.Equal(110, telemetry.ActorRestarted);
Assert.Equal(10, telemetry.ActorRestarted);
// assert no stops recorded
Assert.Equal(0, telemetry.ActorStopped);
}, RemainingOrDefault);
Expand All @@ -296,7 +295,7 @@ await AwaitAssertAsync(async () =>
var telemetry = await subscriber.Ask<TelemetrySubscriber.GetTelemetry>(TelemetrySubscriber.GetTelemetryRequest.Instance);
// assert that actor start count is still 10
Assert.Equal(12, telemetry.ActorCreated);
Assert.Equal(110, telemetry.ActorRestarted);
Assert.Equal(10, telemetry.ActorRestarted);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also need to backport this to v1.4 as well

Copy link
Contributor Author

@Arkatufus Arkatufus Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we didn't caught this in the original PR, I guess we missed it amongst the racy unit test noise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the unit test fix in #6376

Assert.Equal(11, telemetry.ActorStopped);
}, RemainingOrDefault);
}
Expand Down
27 changes: 10 additions & 17 deletions src/core/Akka.Tests/Routing/RoutingSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,27 +294,20 @@ await EventFilter.Exception<ActorKilledException>().ExpectOneAsync(async() =>
}

[Fact]
public async Task Routers_in_general_must_default_to_all_for_one_always_escalate_strategy()
public void Routers_in_general_must_default_to_all_for_one_restart_strategy()
{
var restarter = new OneForOneStrategy(e =>
{
TestActor.Tell(e);
return Directive.Restart;
});

var supervisor = Sys.ActorOf(Props.Create(() => new Supervisor(restarter)));
var router = Sys.ActorOf(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));
var restarted = new HashSet<string>();

supervisor.Tell(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));

var router = await ExpectMsgAsync<IActorRef>();
await EventFilter.Exception<ArgumentException>("die").ExpectOneAsync(async () =>
for (var i = 0; i < 3; i++)
{
router.Tell("die");
});
(await ExpectMsgAsync<ArgumentException>()).Message.Should().Be("die");
await ExpectMsgAsync("restarted");
await ExpectMsgAsync("restarted");
await ExpectMsgAsync("restarted");
ExpectMsg("restarted");
restarted.Add(LastSender.Path.Name);
}

restarted.Count.Should().Be(3);
restarted.Should().BeEquivalentTo(((RoutedActorRef)router).Children.Select(c => c.Path.Name));
}

[Fact]
Expand Down
10 changes: 2 additions & 8 deletions src/core/Akka/Routing/RouterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,9 @@ public override ActorBase CreateRouterActor()
/// <summary>
/// TBD
/// </summary>
public static SupervisorStrategy DefaultSupervisorStrategy
{
get
{
return new OneForOneStrategy(Decider.From(Directive.Escalate));
}
}
public static SupervisorStrategy DefaultSupervisorStrategy => SupervisorStrategy.DefaultStrategy;



public bool Equals(Pool other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down