<html><head></head><body bgcolor="#FFFFFF"><div>One way is to look at mnesia:system_info(running_db_nodes) - see e.g. <a href="https://github.com/uwiger/unsplit/blob/master/src/unsplit_server.erl#L138">https://github.com/uwiger/unsplit/blob/master/src/unsplit_server.erl#L138</a></div><div><br></div><div>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.</div><div><br></div><div>The undocumented function mnesia_lib:have_majority(Tab, ActiveNodes) can also be helpful.</div><div><br></div><div>BR,</div><div>Ulf W<br><br>Ulf Wiger, Feuerlabs, Inc.<div><a href="http://www.feuerlabs.com">http://www.feuerlabs.com</a></div></div><div><br>12 jul 2012 kl. 23:42 skrev Mike Oxford <<a href="mailto:moxford@gmail.com">moxford@gmail.com</a>>:<br><br></div><div></div><blockquote type="cite"><div>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?<div><br></div><div>-mox<br><br><div class="gmail_quote">
On Thu, Jul 12, 2012 at 11:27 AM, Ulf Wiger <span dir="ltr"><<a href="mailto:ulf@feuerlabs.com" target="_blank">ulf@feuerlabs.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><br><div><div class="im"><div>On 12 Jul 2012, at 20:07, Mike Oxford wrote:</div><br><blockquote type="cite">When facing a split with 'majority' enabled, you end up with a reduction in service based on the non-majority nodes.<div>
<br><div>If the interconnect-network is entirely down, then every node is non-majority and will 'freeze.'</div>
<div>If the split is, say, 70/30, then the 30% will not update.</div><div><br></div><div>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?</div>
</div></blockquote><div><br></div></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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).</div><div><br></div>
<div>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. ;-)</div>
<div class="im"><br><blockquote type="cite"><div>
<div>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?</div></div></blockquote><br></div></div><div>That patch was merged in R14B, I believe.</div>
<div><br></div><div>BR,</div><div>Ulf W</div><br><div>
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div>
<div>Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.</div><div><a href="http://feuerlabs.com" target="_blank">http://feuerlabs.com</a></div></div><div><br></div></span><br>
</div>
<br></div></blockquote></div><br></div>
</div></blockquote></body></html>