Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-829

Queries with non-primary read preference on secondaries should set slaveOk flag

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 1.2-beta1
    • libmongoc
    • None

    Description

      From https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#read-operations:

      For all read preferences modes except 'primary', clients MUST set the slaveOK wire protocol flag to ensure that any suitable server can handle the request. Clients MUST NOT set the slaveOK wire protocol flag if the read preference mode is 'primary'.

      In this PR on the PHP driver, I have a test that sends a query to a secondary via mongoc_collection_find() where:

      1. we forcefully set the cursor's hint to that secondary's server ID
      2. we do not pass a read preference to mongoc_collection_find()

      This triggers a "not master and slaveOk=false" error, which seems contrary to the SS spec.

      As an aside: I think we could still trigger a "not master and slaveOk=false" error from the secondary if we passed a primary-only read preference to mongoc_collection_find() and still force the cursor hint.

      Attachments

        Activity

          People

            jesse@mongodb.com A. Jesse Jiryu Davis
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: