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

Fix DistributedForwarder State when running multiple nodes #186

Conversation

scudelletti
Copy link
Contributor

@scudelletti scudelletti commented Dec 13, 2019

Context:

I was trying to setup Commanded with Horde and EventStore and found that something the DistributedForwarder state was empty in some cases, raising an error such as:

14:27:57.931 [error] GenServer Integration.EventStore.EventStore.Registration.DistributedForwarder terminating
** (FunctionClauseError) no function clause matching in :elixir_aliases.do_concat/2
    (elixir) src/elixir_aliases.erl:130: :elixir_aliases.do_concat([[], EventStore.PubSub], "Elixir")
    (elixir) src/elixir_aliases.erl:118: :elixir_aliases.concat/1
    (eventstore) lib/event_store/registration/local_registry.ex:52: EventStore.Registration.LocalRegistry.broadcast/3
    (eventstore) lib/event_store/registration/distributed_forwarder.ex:36: EventStore.Registration.DistributedForwarder.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

This happens when I try to connect 3 nodes following this steps:

  1. Start Node A
  2. Start Node B
  3. Start Node C
  4. In Node C connect to Node A and B.
  5. In Node C dispatch a command.

Here's a repo with a sample app that is able to reproduce the problem, the app is using SwarmRegistry:
https://github.com/scudelletti/eventstore-error

Reasoning behind the change:

Debugging it I found that the init/1 function initializes the state with an empty list. Setting the provided event_store argument seems to fix the problem.
I'm not sure where the state is set if the init/1 function always set it to empty though.

Others

I can try to provide a sample app with the problem if needed, just please let me know.

@slashdotdash thank you for maintaining Commanded and its related libraries. 🎉 💐 ❤️

@slashdotdash slashdotdash merged commit 8b8071d into commanded:master Dec 13, 2019
@slashdotdash
Copy link
Member

Thanks for fixing this issue.

slashdotdash added a commit that referenced this pull request Dec 13, 2019
@scudelletti scudelletti deleted the ds-fix-distributed-forwarder-init-function branch December 13, 2019 21:18
slashdotdash added a commit that referenced this pull request Feb 19, 2020
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

Successfully merging this pull request may close these issues.

2 participants