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

Ask can't find temporary actor inside async context #4384

Closed
Aaronontheweb opened this issue Apr 22, 2020 · 0 comments · Fixed by #4789
Closed

Ask can't find temporary actor inside async context #4384

Aaronontheweb opened this issue Apr 22, 2020 · 0 comments · Fixed by #4789
Assignees
Milestone

Comments

@Aaronontheweb
Copy link
Member

Version: 1.4.4

The following code produces an AskTimeoutException:

public async Task ConsistentHashingPoolRoutersShouldWorkAsExpectedWithHashMapping()
        {
            var poolRouter =
                Sys.ActorOf(Props.Create(() => new ReporterActor(TestActor)).WithRouter(new ConsistentHashingPool(5,
                        msg =>
                        {
                            if (msg is IConsistentHashable c)
                                return c.ConsistentHashKey;
                            return msg;
                        })),
                    "router1");

            // use some auto-received messages to ensure that those still work
            var numRoutees = (await poolRouter.Ask<Routees>(new GetRoutees(), TimeSpan.FromSeconds(2))).Members.Count();

            // establish association between ActorSystems
            var sys2Probe = CreateTestProbe(Sys2);
            var secondActor = Sys.ActorOf(act => act.ReceiveAny((o, ctx) => ctx.Sender.Tell(o)), "foo");

            Sys2.ActorSelection(new RootActorPath(Sys1Address) / "user" / secondActor.Path.Name).Tell("foo", sys2Probe);
            sys2Probe.ExpectMsg("foo");

            // have ActorSystem2 message it via tell
            var sel = Sys2.ActorSelection(new RootActorPath(Sys1Address) / "user" / "router1");
            sel.Tell(new HashableString("foo"));
            ExpectMsg<HashableString>(str => str.Str.Equals("foo"));

            // have ActorSystem2 message it via Ask
            sel.Ask(new Identify("bar2"), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe);
            var remoteRouter = sys2Probe.ExpectMsg<ActorIdentity>(x => x.MessageId.Equals("bar2"), TimeSpan.FromSeconds(5)).Subject;

            var s2Actor = Sys2.ActorOf(act =>
            {
                act.ReceiveAny((o, ctx) =>
                    sel.Ask<ActorIdentity>(new Identify(o), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe));
            });
            s2Actor.Tell("hit");
            sys2Probe.ExpectMsg<ActorIdentity>(x => x.MessageId.Equals("hit"), TimeSpan.FromSeconds(5));
        }

Specifically, this line:

// have ActorSystem2 message it via Ask
sel.Ask(new Identify("bar2"), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe);
var remoteRouter = sys2Probe.ExpectMsg<ActorIdentity>(x => x.MessageId.Equals("bar2"), TimeSpan.FromSeconds(5)).Subject;

From the logs:

DEBUG][4/22/2020 9:11:36 PM][Thread 0042][LocalActorRefProvider(akka://test2)] Resolve of path sequence [/temp/f] failed
[INFO][4/22/2020 9:11:36 PM][Thread 0009][akka://test2/temp/f] Message [ActorIdentity] from akka.tcp://test@localhost:55844/user/router1 to akka://test2/temp/f was not delivered. [1] dead letters encountered .This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

The issue might be with running two ActorSystem instances in the same context, but this is 100% reproducible.

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