Has anyone ever had Registry.dispatch just randomly stop dispatching events?

I have an app that consumes events from a websocket feed. It calls Registry.dispatch/3 to send messages to subscribed genservers, which then in turn prints them to console. The pipelining is handled by genstage. A producer sits on the socket and generates events with receive calls. The consumer then manages a state and dispatches events to processes in a registry if the state is affected in a specific way. The processes subscribed to the registry would log the event when they receive a message via handle_info/2.

After running the app for ~ 20 minutes, the events stop getting logged to the console without anything happening. In the console, I looked at the registry process and saw the processes had unsubscribed as there were no associated registries with that key, but no errors were thrown and everything happened silently. I also was still getting events so the genstage consumer was still consuming events, and its breaking at the registry dispatching point. I can verify the websocket connection did not close, and events were still being read.

This is a replicable issue. The events stop being printed after about the same delay on each run, which is perplexing. That would make me think there’s a leak of some sort somewhere, but the load graphs on the observer seem to indicate that all is fine. Could it be that the registry is getting overloaded? Maybe it’s being tasked to dispatch too many events and can’t send them fast enough, and eventually the process mailbox overflows?

Ooo, I’ve not run across this and I run registry in long-running servers… Any way you could make a short self contained example that we can git clone ... and mix deps.get && mix run to see the issue at hand, even if it does take 20 minutes, even better if you find a way to spam it so fast that it dies sooner? :slight_smile:

1 Like

Do you have SASL logs enabled? If not, I’d try turning them on. That will tell you if any surpervised process dies and gets restarted.

1 Like

@OvermindDL1

I have not yet. How loaded is your registry? Do you also use it for pubsub? I could try to spin something up.

@dom
I have never heard of SASL logs. After doing some digging on google, I am not sure how to incorporate it into my app. Do you have any resources to help me get it set up for my elixir app? Thanks!

No? I use PubSub for PubSub, no point using Registry there as it has it’s own named registry. ^.^

You just enable SASL logging in Elixir’s Logger, all documented at: https://hexdocs.pm/logger/Logger.html

In essence:

config :logger,
  handle_otp_reports: true,
  handle_sasl_reports: true

Add :sasl to applications or extra_applications in your mix.exs (before :logger, if you have it).

The configuration OvermindDL1 mentioned switches the error report format from Erlang syntax to Elixir syntax, it’s optional.

There’s more background in the SASL user’s guide: http://erlang.org/doc/apps/sasl/error_logging.html

1 Like