File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -282,10 +282,25 @@ public String getConnectPoint(){
282282 return master != null ? master .toString () : null ;
283283 }
284284
285+ /**
286+ * This method is called in case of an IOException.
287+ * It will potentially trigger a checkMaster() to check the status of all servers.
288+ * @param t the exception thrown
289+ * @param slaveOk slaveOk flag
290+ * @return true if the request should be retried, false otherwise
291+ * @throws MongoException
292+ */
285293 boolean _error ( Throwable t , boolean slaveOk )
286294 throws MongoException {
295+ if (_rsStatus == null ) {
296+ // single server, no need to retry
297+ return false ;
298+ }
299+
300+ // the replset has at least 1 server up, try to see if should switch master
301+ // if no server is up, we wont retry until the updater thread finds one
302+ // this is to cut down the volume of requests/errors when all servers are down
287303 if ( _rsStatus .hasServerUp () ){
288- // the replset has at least 1 server up, try to see if should switch master
289304 checkMaster ( true , !slaveOk );
290305 }
291306 return _rsStatus .hasServerUp ();
You can’t perform that action at this time.
0 commit comments