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

mongoc_collection_aggregate fails against secondaries

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.0
    • Affects Version/s: 1.6.0
    • Component/s: libmongoc
    • Labels:
      None

      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.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: