[CDRIVER-829] Queries with non-primary read preference on secondaries should set slaveOk flag Created: 04/Sep/15  Updated: 03/May/17  Resolved: 04/Sep/15

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.2-beta1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: A. Jesse Jiryu Davis
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CDRIVER-704 $readPreference sent to non-mongos Closed

 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.



 Comments   
Comment by A. Jesse Jiryu Davis [ 04/Sep/15 ]

Already working on it as we speak.

Generated at Wed Feb 07 21:10:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.