Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mnesia table replication/sharing

Tags:

erlang

mnesia

Assume that we have N erlang nodes, running same application. I want to share an mnesia table T1 with all N nodes, which I see no problem. However, I want to share another mnesia table T2 with pairs of nodes. I mean the contents of T2 will be identical and replicated to/with only sharing pair. In another words, I want N/2 different contents for T2 table. Is this possible with mnesia, not with renaming T2 for each distinct pair of nodes?

like image 951
Haldun Avatar asked Jun 10 '26 12:06

Haldun


1 Answers

It's possible to do this with mnesia's table fragmentation, if one makes use of the mnesia_frag_hash callback behaviour. This allows you to control the distribution of keys, and it would be possible to construct the keys such that the callback is able to determine which node pair (and thus, which fragment) should be used.

Whether or not this works in your particular case depends on your access patterns and data set. Chances are that it's a pretty convoluted approach, and that you'd be better served by simply using different table names instead.

like image 78
uwiger Avatar answered Jun 18 '26 14:06

uwiger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!