"can't find a master" exception even with secondary readPref on a command

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.10.1
    • Component/s: Cluster Management
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have 1 secondary up and running.
      Running following code:

                  try {
                      CommandResult res = db.command(new BasicDBObject("isMaster", 1), 0, ReadPreference.secondaryPreferred());
                  } catch (Exception e) {
                      getLogger().log(Level.INFO, e.getMessage(), e);
                  }
      

      This errors with following:

      INFO: can't find a master
      com.mongodb.MongoException: can't find a master
      	at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:503)
      	at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:236)
      	at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
      	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
      	at com.mongodb.DB.command(DB.java:261)
      	at com.mongodb.DB.command(DB.java:243)
      

      It also fails with:

      • ReadPreference.primaryPreferred()
      • ReadPreference.secondaryPreferred()

      But it works fine using slaveOk:

      CommandResult res = node.getServerDB().command(new BasicDBObject("isMaster", 1), Bytes.QUERYOPTION_SLAVEOK);
      

            Assignee:
            Unassigned
            Reporter:
            Antoine Girbal (Inactive)
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: