Reputation: 12294
Let's consider a MongoDB replica set composed of three nodes (Node 1 being the primary, Node 2 and 3 being secondaries) and a network partition occurs, so Node 1 lose connection to 2 and 3 (but 2 and 3 are connected each other).
So, at the end Node2 and Node3 will elect a new primary (as they have a majority of nodes in their partition). So one of them (depending on priority, votes and oplog time) will end as PRIMARY and the other as SECONDARY.
However, when the old primary (Node 1) realizes that it is no longer a primary, to which state it will transition? I don't refer to the state from the point of view of Node 2 or 3 (that I guess will see Node1 as DOWN) but the state that Node 1 sees itself.
I have looked to replica set states in MongoDB official documentation but I haven't found an clear answer there.
Thanks!
Upvotes: 1
Views: 139
Reputation: 28336
Each of the nodes keeps track of the current status of the other replica set members via heartbeat. Around the time nodes 2 and 3 realize that node 1 isn't responding to them, node 1 will realize that nodes 2 and 3 are not responding to it, so it should log something along the lines of
can't see a majority of the set, relinquishing primary
And then it will transition to secondary.
Upvotes: 2