-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 3.0.3, 3.1.3
-
Component/s: Internal Client
-
None
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
// This is a command with secondary-possible read pref // Only certain commands are supported for secondary operation. BSONObj actualQueryObj; if (strcmp(queryObj.firstElement().fieldName(), "query") == 0) { actualQueryObj = queryObj["query"].embeddedObject(); } else { actualQueryObj = queryObj; }
In practice, the embedded "wrapped" command can have a fieldname of either 'query' or '$query' and we only check for 'query'. The Server Selection spec actually mandates that drivers use '$query': see ( https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#id17).
The effect is that for commands that can run on a secondary, such as inline mapreduce, mongos will incorrectly run the commands on a primary of the shard, even with readPreference mode secondary. Note that this affects drivers OTHER than the shell, which wraps commands with 'query'.
EDIT: in practice this is not an issue as mongos already unwraps the queries (correctly) by the time they reach this point of the codebase.