|
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 }
|
|