MongoDB ReplicaSet Elections when some nodes are down

Posted by SecondThought on Server Fault See other posts from Server Fault or by SecondThought
Published on 2012-05-31T08:16:31Z Indexed on 2012/05/31 10:43 UTC
Read the original article Hit count: 338

Filed under:
|

I'm trying to get into ReplicaSet concept, and found something weird in mongoDB Documentation:

For a node to be elected primary, it must receive a majority of votes. This is a majority of all votes in the set: if you have a 5-member set and 4 members are down, a majority of the set is still 3 members (floor(5/2)+1). Each member of the set receives a single vote and knows the total number of available votes.

If no node can reach a majority, then no primary can be elected and no data can be written to that replica set (although reads to secondaries are still possible).

(taken from here)

So, If I got that right, in the 5-member case mentioned there the one node that's still standing WILL NOT be chosen as primary and the whole set will not get any writes? and that's even if this single node was the last primary before the elections?

If it's true there can be many less-radical cases which will end up with a degenerated set. How can we avoid this?

© Server Fault or respective owner

Related posts about mongodb

Related posts about master-slave