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

Always set slaveOk for direct connections to replica set members

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.6.2
    • Affects Version/s: 3.6.0
    • Component/s: Wire Protocol
    • Labels:
      None

      When an application creates a MongoClient instance that is a direct connection (topology type of "Single" in the parlance of the server selection specification) to a replica set member (e.g. new MongoClient(new ServerAddress("localhost", 27018)), and the read preference mode is "primary", then messages sent to that server via that MongoClient should indicate that the server should execute them regardless of whether the server is the primary member of the replica set.

      For OP_QUERY (for MongoDB versions < 3.6), that means settings the slaveOk wire protocol bit.

      For OP_MSG (for MongoDB versions >= 3.6), that means including a $readPreference field with mode of "primaryPreferred".

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: