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

Two actors are created by remote deploy using Props.WithDeploy #1025

Closed
Al-Dyachkov opened this issue Jun 2, 2015 · 4 comments
Closed

Two actors are created by remote deploy using Props.WithDeploy #1025

Al-Dyachkov opened this issue Jun 2, 2015 · 4 comments

Comments

@Al-Dyachkov
Copy link

I'm trying to use remote deploy using Props.WithDeploy.
Following code illustrates the behaviour (loading configuration etc is not shown )

using( ActorSystem server = ActorSystem.Create( "Server", conf1 ) )
{
  using( ActorSystem client = ActorSystem.Create( "Client", conf2 ) )
  {
    ActorPath p = ActorPath.Parse("akka.tcp://Client@localhost:42001/user");
    Scope sc = new RemoteScope(p.Address);
    Deploy deploy = new Deploy(sc);

    Props props = Props.Create(() => new Test()).WithDeploy(deploy);
    server.ActorOf(props, "Test");
  }
}

conf1/2 is loaded from standard configuration (with port 42000 for server and 42001 for client)

akka
{
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
}
remote {
helios.tcp {
port = 42001
hostname = localhost
}
}
}

Test is blank actor.

Running this sample makes Test to be instantinated twice.
Logs show two records

[DEBUG][02.06.2015 19:29:21][Thread 0001][LocalActorRefProvider(akka://Server)] [akka://Server/] Instantiating Remote Actor [akka.tcp://Client@localhost:42001/remote/akka.tcp/Server@localhost:42000/user/Test]

This behaviour is the same when ActorSystems are located in different processes.

When same approach is used for "plug-in" scenario

  1. Client connects to server and sends specific message to specific actor
  2. Actor processes the message and remotely deploys child actor on Sender like
 private void OnClientConnected(ClientConnected Message) 
 {
  Scope sc = new RemoteScope(Sender.Path.Address);
  Deploy deploy = new Deploy(sc);
  Props props = Props.Create( () => new Test() ).WithDeploy( deploy );
  Context.ActorOf(props, "Test");
}

Two actors are instantiated on a client again, but Context.GetChildren() yields only one child actor

@rogeralsing
Copy link
Contributor

I've tested the example and can verify that this is going on.

I also debugged the actor hashcode and context hashcode that clearly shows that both the context and the actor are different instances in both cases.

Both contexts has the same Self path, so it seems like remote deploy in some way creates two instances and ignores one of them.
This is a critical bug because if the actor decides to send self referenses out to other actors, things will go bananas..

As the context hascode is different, this is clearly not a matter of superviosion either. its something bigger going on.

actor 34699204 context 33275123
actor 30762424 context 8627704

@rogeralsing
Copy link
Contributor

Investigating.
There are two different actor cells both receiveing the exact same envelope (as in the same instance)

@rogeralsing
Copy link
Contributor

This code is invoked twice in Endpoint.cs

cc @Aaronontheweb

Any ideas why?

            // message is intended for the RemoteDaemon, usually a command to create a remote actor
            if (recipient.Equals(remoteDaemon))
            {
                if (settings.UntrustedMode) log.Debug("dropping daemon message in untrusted mode");
                else
                {
                    if (settings.LogReceive) log.Debug("received daemon message [{0}]", msgLog);
                    remoteDaemon.Tell(payload);
                }
            }

@rogeralsing rogeralsing added the WIP label Jun 2, 2015
@rogeralsing
Copy link
Contributor

actor.Start() is called twice from different locations. resulting in a DaemonMsgCreate message being sent twice to the remote daemon.

start1
start2

Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this issue Jun 2, 2015
Horusiath pushed a commit to Horusiath/akka.net that referenced this issue Jul 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants