Search code examples
javamongodbmongodb-java

MongoDB Java Driver Replica Set Failover


I have a MonogDB replica set with 2 members and an arbiter. The problem is when the primary node goes down and mongo is selecting a new primary I have some data loss. I believe this is something I can control on the Java driver level.Please help me find the right settings so I don't have any data loss when failover occurs


Solution

  • During a primary election any writes will result in exceptions and you'll have to retry those writes or relay any messages back to the user. There is no built in logic for retries so you'll have to write your own retry handlers.