1

My mongo db has three replicas 1 is the primary node and 2,3 is the secondary nodes. Suppose the following sequence of event happens

1) Replica 1 writes document A and it is replicated to 2,3

2) Replica 1 writes document B but does not manage it to copy to any other replica for some reason.

3) Replica 1 faced some failure

What should be the next steps happens. I knew that the election will take place between 2, 3 and one of them will become primary and other secondary and operation continues to work but what about the document B record in 1, should it be replicated when 1 recovers from failure ?

Ghazanfar Khan
  • 3,648
  • 8
  • 44
  • 89

2 Answers2

1

https://docs.mongodb.com/manual/core/replica-set-rollbacks/:

... if the primary had accepted write operations that the secondaries had not successfully replicated before the primary stepped down. When the primary rejoins the set as a secondary, it reverts, or “rolls back,” its write operations to maintain database consistency with the other members.

seems pretty clear

Alex Blex
  • 34,704
  • 7
  • 48
  • 75
0

To prevent rollbacks of data that have been acknowledged to the client, run all voting members with journaling enabled and use w: majority write concern to guarantee that the write operations propagate to a majority of the replica set nodes before returning with acknowledgement to the issuing client.