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

Get Remote Actor fail #41

Open
hemaolong opened this issue Apr 18, 2024 · 1 comment
Open

Get Remote Actor fail #41

hemaolong opened this issue Apr 18, 2024 · 1 comment

Comments

@hemaolong
Copy link

When I run the distribute example, the worker sometimes can not get the remote actor.
It seems that the registry return Ok but with Nothing(None):

received actor node (current_node=example-worker, actor_id=echo-actxor, actor_node=None)
        match self
            .inner
            .registry_ref
            .send(GetActorNode {
                actor_id: actor_id.clone(),
                sender: tx,
            })
            .await
        {
            Ok(_) => {
                // TODO: configurable timeouts (?)
                match tokio::time::timeout(tokio::time::Duration::from_secs(5), rx).await {
                    Ok(Ok(res)) => {
                        trace!(
                            "received actor node (current_node={}, actor_id={}, actor_node={:?})",
                            self.node_tag(),
                            &actor_id,
                            &res
                        ); 
                        res
@hemaolong
Copy link
Author

I think this is a time-sequence problem. The "this.nodes" is not all ready will get the wrong node id.

#[async_trait]
impl Handler<GetActorNode> for RemoteRegistry {
    async fn handle(&mut self, message: GetActorNode, _: &mut ActorContext) {
        // let span = tracing::trace_span!(
        //     "RemoteRegistry::GetActorNode",
        //     actor_id = message.actor_id.as_str()
        // );
        //
        // let _enter = span.enter();

        let id = message.actor_id;
        let current_system = self.system.as_ref().unwrap().node_id();
        // Not all nodes registered.
        let assigned_registry_node = self.nodes.get_by_key(&id).map(|n| n.id);

        let assigned_registry_node = assigned_registry_node.map_or_else(
            || {
                trace!("no nodes configured, assigning locally");
                current_system
            },
            |n| n,
        );

        trace!("{:?}", &self.nodes.get_all());

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

No branches or pull requests

1 participant