Data consistency: No primary on no majority

I have this question, how the logic is a better fail safe mechanism for data consistency when there is one active node in a majority configuration of the replica set.
This blocks any write, the client can’t write and hence loss of data and of course not a nice user experience.
Why can’t the last active node of the replica set be promoted as primary, so that the write operation can go through, and as and when the secondary comes up, opcode can be used to replicate the data in secondary nodes!
Please help to answer my doubt.

The short answer is, it’s a minimum requirement to have at least 2 nodes (1 primary and 1 secondary) and a recommendation to have a minimum of 3 nodes. Increase the number of nodes, share them across data centres to increase fault tolerance and availability.

1 Like

thanks for the answer, makes sense if we have to adhere to the minimum requirement.
But i find the situation as an oxymoron: secondary nodes were added for high data availability, now when all secondary nodes go down, there is no data availability :slight_smile:

Yeah, kind of is :slight_smile: . But that’s the way it’s designed.

If there’s no primary, then it can’t guarantee that your data has been replicated and as a result it will not accept anymore writes. Reads, however, as you already know, are allowed… which also implies “availability”.

A good design strategy will ensure high availability overall.

1 Like

thanks, another doubt arising from your answer, reads can only happen if we manually set “rs.slaveOk()”, right? otherwise read also can’t happen.

Yes that’s right, and also Read Preference. And funny enough, the latter is the preferred option. :sweat_smile:

I had not reached the “Read Preferences” lecture, watching it now.
primaryPreferred, would solve the issue that I was referring at.
Thanks

Yeah, it was just a play of words between Read Preference and preferred :slight_smile:

Perhaps this thread might help:

Enjoy the course!

1 Like

thanks a lot for the thread, :slight_smile:
I understand better now, we have to live with the limitation.