Setting ReadPreference.PRIMARY on a find has no effect if slaveOk=true has been set in the connection string

XMLWordPrintableJSON

    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When the connection string contains slaveOk=true as an option then the following line of (groovy) code may read from a secondary server in a replica set:

      collection.findOne(new BasicDBObject([_id: key]),null, ReadPreference.PRIMARY)

      I believe that this may well affect all find methods.

      This appears to be due to the code in OutMethod.appendQuery() which ORs in Bytes.QUERYOPTION_SLAVEOK if the read preference is NOT primary but does nothing if the read preference is primary.

              Assignee:
              Unassigned
              Reporter:
              Chris Barrett
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: