[CDRIVER-2357] "not master" error directly querying secondary with OP_MSG Created: 10/Nov/17  Updated: 28/Oct/23  Resolved: 12/Nov/17

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.9.0
Fix Version/s: None

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

Issue Links:
Depends
Related
is related to CDRIVER-2219 OP_MSG support Closed
Epic Link: Cdriver MongoDB 3.6 Support

 Description   

In the OP_QUERY wire protocol we can directly connect to a secondary by setting the slaveOkay bit for all messages when TopologyType is Single. With OP_MSG there's no such bit, so reads are rejected with "not master and slaveOk=false".

Solution: include {$readPreference: "primaryPreferred"} with all messages if there's no read preference, the wire protocol is OP_MSG, and TopologyType is Single.

Refactor the existing code in mongoc-cursor.c and mongoc_collection_aggregate that does this especially for cursors with a serverId set.



 Comments   
Comment by Githook User [ 13/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2357 query secondaries with OP_MSG, part 3

Injecting read preference primaryPreferred in "getMore" commands is ok.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/af7ca3d1df0764bca45bd6dacdb3c87472e32b60

Comment by Githook User [ 13/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2357 query secondaries with OP_MSG, part 2
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/d41d16b23e0d1592f59dc5314b4932a23e721bd4

Comment by Githook User [ 12/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2357 refactor cursor options logic
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/76cab91be40d809dff6676ab8ee59e05b32f097d

Comment by Githook User [ 12/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2357 query secondaries with OP_MSG
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/340d8a4caaa8bd3c60227fae53db912fea284cd9

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