I've noticed a few peculiarities about MongoDB replica sets.
In a 3-node replSet, if the PRIMARY goes down, I see that the set elects a new PRIMARY and everything is fine without experiencing any downtime. But if another member goes down (2 total down), the 1 remaining member does not become PRIMARY and a complete outage happens. I understand this is because the replSet does not have a majority for an election.
But this seems silly.. shouldn't my 1 surviving member be able to function on its own? Is there a way to configure it so that I get this behavior?
I understand that arbiters can be used to achieve majority, however, if I add an arbiter for a total of 4 members, an even number, then wouldn't this also run into problems with majorities? Or, if I add 2 arbiters for a total of 5 voting members but 1 goes down, wouldn't I be left with an even number of voting members and still suspect to the replSet not being able to elect a PRIMARY?
In general I'm a little confused about how "majority" is established with regards to what happens when members go up or down, and what configuration options I have. My specific questions are:
- How do I protect against an outage in a 3-node replSet when 2 members go down, and/or what is the best practice for safely remediating an outage that happens in this scenario?
- In an odd-member replSet, what happens when an odd number of members go down and leave the replSet with an even number of members online (with respect to the replSet being able to do a majority election)?