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(){
282
282
return master != null ? master .toString () : null ;
283
283
}
284
284
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
+ */
285
293
boolean _error ( Throwable t , boolean slaveOk )
286
294
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
287
303
if ( _rsStatus .hasServerUp () ){
288
- // the replset has at least 1 server up, try to see if should switch master
289
304
checkMaster ( true , !slaveOk );
290
305
}
291
306
return _rsStatus .hasServerUp ();
You can’t perform that action at this time.
0 commit comments