From my understanding, you should have an uneven number of voting members in a replica set to avoid a tie in the vote.

What I don’t understand however, is why it should be an uneven number because when the primary goes down, isn’t there one less voting member?
So in the case of 3 nodes, the primary goes down and now there’s only 2 nodes which can result in a tie.

I probably have an error in my thinking, can someone explain to me, what it is?

Ties might happen, but a new election will happen. The probability of multiple ties when the 2 remaining nodes can communicate is small.

More can be found at https://docs.mongodb.com/manual/core/replica-set-elections/

Yes, that’s correct. But why does it say multiple times in the video that you should have an uneven amount of nodes?

Does the clean way of rs.stepDown() happen much more often than an unexpected shutdown?
Because in that case, having 3 nodes is fine and you can’t have a tie.
In the event of an unexpected shutdown however, you could get a tie.

So either way it can result in a tie, depending on the way the primary was shutdown.

Am I correct to assume you should have an uneven number because the orderly shutdown happens much more often?

P.S. thank you for the link, it was very insightful.

Hi @Darius_Nein,

Yes. Having an uneven number of nodes guarantees that there would never be a tie. There are also other circumstances which can trigger an election in the replica set other than the two cases that you have mentioned.

The criteria for selecting a `Primary` is based on a set of rules. The way voting members cast their vote in election is also based on some set of rules and the node which has elected itself to be the `Primary` must satisfy those criteria. For instance, it should have more recent oplog entry than the voting member node otherwise it wouldn’t get the vote from that particular voting member. Hence the chances of tie is very low.

Hope it helps!

~ Shubham

I have a doubt. What if there are three nodes in the replica set, and in the event of election, all nodes decide to vote for itself. Doesn’t this result in tie ?