-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Cluster Management, Error Handling
-
None
When the driver is configured to work with a replica set, it still favors a single node in the replica set. If that node becomes unavailable, the next request will invalidate the connection and return failure. A subsequent request will attempt to reconnect to the replica set, thereby establishing a connection to a different node, and therefore succeed. Thus, in a failover scenario, one (or maybe more) requests are lost.
How we deal with this at the AKC is to use a "retry" aspect; it advises every interaction with MongoDB, and if the interaction returns an UncategorizedMongoException or DataAccessResourceFailureException, it resubmits the request one time. That way, in a failover, we give ourselves the chance to have zero lost requests.
While we have a code solution for this, I'd like it if this were supported by the official distribution. I've included our aspect for reference.