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

SupervisionStrategy is ignored when set on a routee #74

Open
object opened this issue Nov 24, 2017 · 6 comments
Open

SupervisionStrategy is ignored when set on a routee #74

object opened this issue Nov 24, 2017 · 6 comments
Labels

Comments

@object
Copy link
Collaborator

object commented Nov 24, 2017

I noticed that Akkling behaves differently comparing to Akka.FSharp API when it comes to specifying supervision strategy for routers.

Let's say I want to set the following strategy to manage exceptions on router children:

let routeeStrategy () =
Strategy.OneForOne((fun ex ->
Console.WriteLine("Invoking routee strategy")
Console.WriteLine("Restarting actor")
Directive.Restart)

So when creating a router I pass this strategy:
spawn mailbox.UntypedContext actorId { props workerActor with Router = Some routerConfig; SupervisionStrategy = Some <| routeeStrategy() } |> ignore

I also set a strategy on the higher level actor (router supervisor):

let routerStrategy () =
Strategy.OneForOne(fun ex ->
Console.WriteLine("Invoking router strategy")
Console.WriteLine("Resuming actor")
Directive.Resume)

and create a supervisor:
let supervisor = spawn system "runner" <| { props supervisingActor with SupervisionStrategy = Some <| routerStrategy() }

What happens is that the first (routee) strategy is never applied: whenever exception occurs at a routee level, the routerStrategy is applied and the actor is always resumed.

But if I set routeeStrategy when creating a supervisor, then the router itself will be restarted (with all routees). And I only want to restart the single child.

So I am bit lost right now: how do I set two different strategies for the router and its children. Am I overlooking something?

@object
Copy link
Collaborator Author

object commented Nov 24, 2017

To summarize in short, it looks like in the statement

{ props workerActor with Router = Some routerConfig; SupervisionStrategy = Some <| routeeStrategy() }

the SupervisionStrategy property is never used when the Router is not None.

@object
Copy link
Collaborator Author

object commented Nov 24, 2017

... and it works if I specify SupervisionStrategy like this:

let routerConfig = FromConfig.Instance.WithSupervisorStrategy(routeeStrategy()) :> RouterConfig

Then the question: shouldn't it also work if SupervisionStrategy is set like in the example above? Otherwise it's just ignored.

@Horusiath
Copy link
Owner

Is it the case only for routers or for all kinds of actors?

@object
Copy link
Collaborator Author

object commented Nov 25, 2017

No this happens only with routers. Since I have now both working and not working scenarios I can look more into this and hopefully come with a PR.

Horusiath added a commit that referenced this issue Nov 26, 2017
@Horusiath Horusiath added the bug label Nov 27, 2017
@Horusiath
Copy link
Owner

I've added a test that confirms the issue. However it looks like the supervisor strategy is correctly attached to props, it just doesn't get triggered for some reason.

@object
Copy link
Collaborator Author

object commented Dec 22, 2017

That's weird. Because it gets triggered for the original F# API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants