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

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement