MongoDB Failover Process Explained

failovermongodb

Hello guys I've been all over the MongoDB documentation (http://docs.mongodb.org) and I can't find a solution to my problem. Imagine the following scenario:

I have 2 Nodes (1000Km apart). Both nodes can communicate with the other;
Node1 has several replicasets and therefore several Masters, Slaves and Arbiters;
Node2 has a replica (slave) and a hidden replica (hidden slave) of each Master in Node1.
Here's a diagram to help you guys understand
enter image description here

I want to know what might happen if:

The link between the two nodes fails;
My guess is the non hidden slaves in Node2 will be elected Masters. What happens when the link between nodes returns? 2 masters?

Node 1 fails completely;
Same scenario? 2 Masters when Node1 returns?

Is this the best way to do this? Any sugestions on how should I do it so I won't lose any information if Node1 fails completely (avoiding the two masters situation)

Best Answer

So assuming that node(n) is a physical box, and the host(n) is a mongod process...If the link between the nodes fails, nothing cool will happen :).

node1 will continue operating as normal, and node2 will just sit there asking wtf. The regular secondary will only have 2/4 votes which is not the strict majority.

If node1 fails, then you will have to manually configure the secondary on node2 as the primary.

When node1 comes back online, the previous primary will come back online as a secondary and it will detect any unfinished writes, and do a rollback which will require manual intervention.

Keeping in mind that you need a strict majority to elect a new primary, I would try putting the arbiters on their own system that is independent of the two nodes.