Mongodb – what will happen if MongoDB primary host is down and secondary is out of sync. will we lose transaction

database-designmongodbmongodb-4.0replication

In our environment, we have one primary(A) and two secondaries(B & C nodes) running in Mongodb 4.0 version. secondary(C) server is newly added and sync is happening on that. Cluster is running only with A and B servers. Now, the Primary server(A) was abruptly down due to some host issue and it was not responding and we could also see that secondary server(B) was out of sync for 10 minutes. we were able to bring up only "B" as new primary. what will happen to the transactions that were completed in old primary (A) and that was not synced with secondary(B).? Please answer.

Best Answer

When you managed to get that A running, it will roll-back all those transactions what are not on B, because now B have newer transactions and it's Primary. That you get when you "force" Secondary to be primary against replica sets will.