Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-848

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.10.1
    • Cluster Management
    • None

    Description

      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);

      Attachments

        Activity

          People

            Unassigned Unassigned
            antoine Antoine Girbal
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: