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

secondary readPrefs require a primary in the replica-set to retrieve more than 101 results

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • 2.12.0
    • Affects Version/s: 2.11.0
    • Component/s: None
    • None

      getMore command behind DBCursor.hasNext appears to require that a primary exists in the replica-set somewhere. It does not require a connection to it (AFAIK) but it insists that a primary be nominated.

      Reproduction:
      1. Set up a 3 node replica-set (PSS).
      2. Kill 2 nodes.
      3. Run Java client with a readPreference of secondary and perform a simple query.
      4. Call hasNext on the returned cursor until 101 results.
      5. Stack trace follows:

      Caused by: com.mongodb.MongoException: can't find a master
      at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:517)
      at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:236)
      at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
      at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:184)
      at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:427)
      at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:396)
      at com.mongodb.DBCursor._hasNext(DBCursor.java:464)
      at com.mongodb.DBCursor.hasNext(DBCursor.java:484)

      It would seem the first DBTCPConnnector.call passes "null" as a readPref to the counterpart which dutifully passes that through to DBTCPConnector.innerCall which defaults to primary (because null readpref) and the getMore helper has constructed an OutMessage instance with no readpref either. Thus checkMaster is erroneously called with "true" for "failIfNoMaster".

            Assignee:
            Unassigned Unassigned
            Reporter:
            andrew.ryder@mongodb.com Andrew Ryder (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: