gpreston

gpreston

Mnesia with dynamic node list via fly.io

Hi all, I’m having trouble on the final mile of solving a problem using Mnesia. The use cases details are:

  • I have multiple nodes that each track some local in-memory state (for me these are specifically streams, so I will call them that)
  • Each node needs to be able to ask a small set of questions about the global state, specifically “what are all the streams that are running?
  • The cluster is deployed on fly.io, which auto start/stops machines based on usage.

To accomplish this, Mnesia seemed like a natural choice, being built-in to the BEAM. However, I keep running into the same problem which manifests in a few ways: Mnesia wants to know on start-up which nodes to put a table on.

  • the first issue with this is dns_cluster, which fly.io uses by default, discovers nodes after the application is started. I’d think this is fine, because my schema is more or less “stream ID => stream metadata”, and stream IDs are unique (and if there is a conflict, some kind of handling can be defined), so this connect-after-start could simply merge Mnesia tables. This also is the same problem as scaling to another region without wanting to re-deploy the application.
  • The next problem is Mnesia tables don’t like to merge. If they were defined with different node lists, one of them essentially has to be deleted while the other is replicated to the new node. I feel like I could program this but it just sounds like a pain to manage, feels like a solution should already exist, and feels like it means a network split is impossible to smoothly recover from. Even if one of the tables is empty, as long as it exists, Mnesia makes a fuss.

So I am wondering:

  1. Is there a better, simpler solution for my use case that I’m not thinking of?
  2. If Mnesia can actually work well here, what am I missing about table merging to make it possible?

Thanks for any insight!

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement