Reputation: 4175
What would be given priority in mongodb replicaset's election process - priority or votes ? I mean, if I have successive priority set for all member nodes of a replicaset, will it ever go into a deadlock?
For instance, if I have a mongodb replicaset with 4 nodes and no arbiter. All of them have priority set, like node01 has 25, node02 has 20, node03 has 15, and node04 has 10.
Is there any chance of a deadlock in the election process, in the above case?
Upvotes: 3
Views: 743
Reputation: 36
Votes and priority are two different things.. Mongo needs more than 50% of votes to elect a primary, if we have less than 50% of votes then all alive nodes become secondary.
Priority setting of replica set ensure that higher priority members are more likely to become primary than others which have low priority.
Node1:25 > Node2:20 > Node3:15 > Node4:10 is the sequence of your primaries.
NOTE:
And for you questions:
What would be given priority in mongodb replicaset's election process - priority or votes ?
Ans: votes
I mean, if I have successive priority set for all member nodes of a replicaset, will it ever go into a deadlock? Ans: Never.
Upvotes: 0
Reputation: 1935
In a given replica set with 4 nodes and their corresponding priority :=> node1:25,node2:20,node3:15,node4:10. Let us say node1(primary,with the highest priority) has gone down then elections will be triggered and node2 will be elected as the next primary(in order of priority) provided that it receives votes from a majority members of the replica set. Even theoretically there is no possibility of a deadlock. Setting non-defaut priority values for a replica set node might be useful when you want a node to be the preferred 'primary' node during election/failover.
Note - Since v2.6 of mongoDB every eligible node can vote only once.
Upvotes: 2