[erlang-questions] mnesia and majority
Ulf Wiger
ulf@REDACTED
Fri Jul 13 00:43:58 CEST 2012
One way is to look at mnesia:system_info(running_db_nodes) - see e.g. https://github.com/uwiger/unsplit/blob/master/src/unsplit_server.erl#L138
But since the 'majority' option is table-specific, I'd go for mnesia:table_info(Tab, where_to_wlock), which returns {ActiveNodes, Majority} - that is, how many replicas it sees, and whether the table has the 'majority' option enabled.
The undocumented function mnesia_lib:have_majority(Tab, ActiveNodes) can also be helpful.
BR,
Ulf W
Ulf Wiger, Feuerlabs, Inc.
http://www.feuerlabs.com
12 jul 2012 kl. 23:42 skrev Mike Oxford <moxford@REDACTED>:
> Interesting, thanks. So how does one identify, when the network comes back up, that "node X was in the majority" so that you can set the master node appropriately?
>
> -mox
>
> On Thu, Jul 12, 2012 at 11:27 AM, Ulf Wiger <ulf@REDACTED> wrote:
>
> On 12 Jul 2012, at 20:07, Mike Oxford wrote:
>
>> When facing a split with 'majority' enabled, you end up with a reduction in service based on the non-majority nodes.
>>
>> If the interconnect-network is entirely down, then every node is non-majority and will 'freeze.'
>> If the split is, say, 70/30, then the 30% will not update.
>>
>> But then once the network is back up, does it automatically replay the missing transactions on the 30% from the 70%? In a full-network-down situation where every node halts the write, when the network comes back up will everything re-mesh on its own?
>
> Mnesia does no automatic merge. It can detect that a split has happened, and if you have 'majority' enabled, you can trust that you have avoided inconsistency, and can proceed to identify a majority island.
>
> Mnesia doesn't give you much help with this, although you can spy into the "unsplit" code for _one_ way to do it. Another could be to have a "backdoor ping", e.g. via UDP, and -kernel dist_auto_connect false. This way, you can exchange information between "islands" and control when they are to reconnect.
>
> The standard mnesia-supported way to resolve the situation would then be to restart the nodes in the minority island, after having called mnesia:set_master_nodes(Tables, MajorityNodes).
>
> This has always been seen as something of a sledgehammer, but given that the minority nodes are not able to write to the database anyway, it is somewhat less so when combined with the 'majority' option. ;-)
>
>> Or do I need something like Ulf's "unsplit" handlers? Does mnesia still need to be patched to support "unsplit" or was that merged as well?
>
> That patch was merged in R14B, I believe.
>
> BR,
> Ulf W
>
> Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
> http://feuerlabs.com
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120713/edc17e1b/attachment.htm>
More information about the erlang-questions
mailing list