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.
- is related to
-
CXX-1284 aggregate on secondary fails plus max_staleness assertion heisenbug
-
- Closed
-