com.mongodb.MongoException: Rare case where master=null, probably all servers are down

JIRA | Jeff Yemin | 4 years ago
  1. 0

    The fix for JAVA-656 introduced a regression. In the case where you have use the Mongo constructor that takes a list of ServerAddress, or a MongoURI with a list of server addresses, _masterPortPool starts as null. Before this change, the checkMaster call would block until an initial master was found. Now that it no longer does, there is a race between the background thread and application threads. If an application only does non-primary reads, and the list of servers is a list of mongos, until a write is done, then ensureMaster will never be called and you will keep getting this exception: {noformat} 10-25-2012 17:01:00 [Thread-427] ERROR com.xgen.svc.mms.svc.ping.BatchPrePopulationSvc [run:136] - Rare case where master=null, probably all servers are down com.mongodb.MongoException: Rare case where master=null, probably all servers are down at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:434) ~[mongo.jar:na] at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:276) ~[mongo.jar:na] at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:256) ~[mongo.jar:na] at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:289) ~[mongo.jar:na] at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:274) ~[mongo.jar:na] at com.mongodb.DBCursor._check(DBCursor.java:368) ~[mongo.jar:na] at com.mongodb.DBCursor._hasNext(DBCursor.java:459) ~[mongo.jar:na] at com.mongodb.DBCursor.hasNext(DBCursor.java:484) ~[mongo.jar:na] {noformat} This test demonstrates the problem. {code:java} public class JAVA656Test { public static void main(String[] args) throws UnknownHostException { Mongo mongo = new Mongo(Arrays.asList(new ServerAddress("localhost:30999"))); mongo.setReadPreference(ReadPreference.secondary()); DBCollection collection = mongo.getDB("test").getCollection("JAVA656Test"); for (int i = 0; i < 5; i++) { try { collection.findOne(); } catch (MongoException e) { System.out.println(e.getMessage()); } } System.out.println("Inserting"); collection.insert(new BasicDBObject()); System.out.println("Trying again"); collection.findOne(); System.out.println("Done"); } } {code} Output is: {noformat} Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Inserting Trying again Done {noformat}

    JIRA | 4 years ago | Jeff Yemin
    com.mongodb.MongoException: Rare case where master=null, probably all servers are down
  2. 0

    The fix for JAVA-656 introduced a regression. In the case where you have use the Mongo constructor that takes a list of ServerAddress, or a MongoURI with a list of server addresses, _masterPortPool starts as null. Before this change, the checkMaster call would block until an initial master was found. Now that it no longer does, there is a race between the background thread and application threads. If an application only does non-primary reads, and the list of servers is a list of mongos, until a write is done, then ensureMaster will never be called and you will keep getting this exception: {noformat} 10-25-2012 17:01:00 [Thread-427] ERROR com.xgen.svc.mms.svc.ping.BatchPrePopulationSvc [run:136] - Rare case where master=null, probably all servers are down com.mongodb.MongoException: Rare case where master=null, probably all servers are down at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:434) ~[mongo.jar:na] at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:276) ~[mongo.jar:na] at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:256) ~[mongo.jar:na] at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:289) ~[mongo.jar:na] at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:274) ~[mongo.jar:na] at com.mongodb.DBCursor._check(DBCursor.java:368) ~[mongo.jar:na] at com.mongodb.DBCursor._hasNext(DBCursor.java:459) ~[mongo.jar:na] at com.mongodb.DBCursor.hasNext(DBCursor.java:484) ~[mongo.jar:na] {noformat} This test demonstrates the problem. {code:java} public class JAVA656Test { public static void main(String[] args) throws UnknownHostException { Mongo mongo = new Mongo(Arrays.asList(new ServerAddress("localhost:30999"))); mongo.setReadPreference(ReadPreference.secondary()); DBCollection collection = mongo.getDB("test").getCollection("JAVA656Test"); for (int i = 0; i < 5; i++) { try { collection.findOne(); } catch (MongoException e) { System.out.println(e.getMessage()); } } System.out.println("Inserting"); collection.insert(new BasicDBObject()); System.out.println("Trying again"); collection.findOne(); System.out.println("Done"); } } {code} Output is: {noformat} Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Rare case where master=null, probably all servers are down Inserting Trying again Done {noformat}

    JIRA | 4 years ago | Jeff Yemin
    com.mongodb.MongoException: Rare case where master=null, probably all servers are down
  3. 0

    Lots of index failures throws error in Web UI

    GitHub | 3 years ago | jaxxstorm
    com.mongodb.MongoException: too much data for sort() with no index. add an index or specify a smaller limit
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    $all ArrayList problem with version 0.3-early-20121119-1140

    GitHub | 4 years ago | ihr
    com.mongodb.MongoException: $all requires array
  6. 0

    GeoSpatial Near Criteria Not working with radius [moved]

    GitHub | 4 years ago | jyemin
    com.mongodb.MongoException: invalid operator: $sphere

  1. sriharshakiran 2 times, last 7 months ago
5 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. com.mongodb.MongoException

    Rare case where master=null, probably all servers are down

    at com.mongodb.DBTCPConnector$MyPort.get()
  2. MongoDB Java Driver
    DBCursor.hasNext
    1. com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:434)[mongo.jar:na]
    2. com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:276)[mongo.jar:na]
    3. com.mongodb.DBTCPConnector.call(DBTCPConnector.java:256)[mongo.jar:na]
    4. com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:289)[mongo.jar:na]
    5. com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:274)[mongo.jar:na]
    6. com.mongodb.DBCursor._check(DBCursor.java:368)[mongo.jar:na]
    7. com.mongodb.DBCursor._hasNext(DBCursor.java:459)[mongo.jar:na]
    8. com.mongodb.DBCursor.hasNext(DBCursor.java:484)[mongo.jar:na]
    8 frames