[CDRIVER-2098] mongoc_collection_aggregate fails against secondaries Created: 23/Mar/17  Updated: 03/May/17  Resolved: 27/Mar/17

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.6.0
Fix Version/s: 1.7.0

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

Attachments: File demo.c    
Issue Links:
Related
is related to CXX-1284 aggregate on secondary fails plus max... Closed

 Description   

In investigating CXX-1284, I discovered that libmongoc can't run aggregation with secondary read preferences.

See the attached demonstration file. When run and given a replica set connection string, the output appears as follows:

$ ./demo $MONGOD
Testing with URI 'mongodb://metis.local:50049,metis.local:50909,metis.local:51425/?replicaSet=foo' and no specified read preference.
{ "_id" : { "$oid" : "58d45d435a4e40805d08bb62" } }
{ "_id" : { "$oid" : "58d45d435a4e40805d08bb63" } }
{ "_id" : { "$oid" : "58d45d435a4e40805d08bb64" } }
{ "_id" : { "$oid" : "58d45d435a4e40805d08bb65" } }
{ "_id" : { "$oid" : "58d45d435a4e40805d08bb66" } }
 
Testing with URI 'mongodb://metis.local:50049,metis.local:50909,metis.local:51425/?replicaSet=foo&readPreference=secondary' and no specified read preference.
Error: 'not master'
 
Testing with URI 'mongodb://metis.local:50049,metis.local:50909,metis.local:51425/?replicaSet=foo' and secondary read preference.
Error: 'not master'
 
Testing with URI 'mongodb://metis.local:50049,metis.local:50909,metis.local:51425/?replicaSet=foo&readPreference=secondaryPreferred' and no specified read preference.
Error: 'not master'
 
Testing with URI 'mongodb://metis.local:50049,metis.local:50909,metis.local:51425/?replicaSet=foo' and secondaryPreferred read preference.
Error: 'not master'

There are some suspicious looking comments in mongoc_collection_aggregate about setting or not setting slaveOK by function calls that don't seem to have anything to do with setting flags.

Compared to mongoc_collection_find, mongoc_collection_aggregate doesn't seem to use the same COALESCE logic for setting up its cursor.



 Comments   
Comment by Githook User [ 27/Mar/17 ]

Author:

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

Message: CDRIVER-2098 aggregate with read pref sets slaveOk
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/deaa5608979a4b0a82b42eabe98fb9385128cbc0

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