Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7768

aggregate command fails with $readPreference

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.3.2
    • Affects Version/s: 2.2.0, 2.2.1
    • Component/s: Aggregation Framework
    • None
    • ALL

      Note: this seems to only be a problem with the aggregate command. In 2.2.x all other commands seem to ignore $readPreference (support is implemented in 2.3.1 for SERVER-7423)

      This effects at least the Java and Python drivers, which always send $readPreference to mongos for certain white listed commands.

      aggregate without $readPreference, no issues:

      mongos> db.runCommand({'aggregate': 'test', 'pipeline': [{'$project': {'_id': false, 'foo': true}}]})
      { "result" : [ { }, { "foo" : "bar" } ], "ok" : 1 }
      

      aggregate with $readPreference, errors:

      mongos> db.runCommand({'aggregate': 'test', 'pipeline': [{'$project': {'_id': false, 'foo': true}}], $readPreference: {'mode': 'primary'}})
      { "ok" : 0, "errmsg" : "unrecognized field \"$readPreference" }
      

      count (as one counter-example) with $readPreference, no issues:

      mongos> db.runCommand({'count': 'test', query: {}, $readPreference: {'mode': 'primary'}})
      { "shards" : { "shard0000" : 2 }, "n" : 2, "ok" : 1 }
      

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: