-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.5.2
-
Component/s: None
-
Environment:Ubuntu 12.04
Mongos / mongod: 2.4.5
This fix in PYTHON-446 appears to cause some issues.
Situation:
I have a replicaset, accessed via a mongos.
Goal:
I'm attempting to perform an aggregation against a secondary, using SECONDARY_PREFERRED. Initially, slave_okay was unset (the documentation says it is deprecated)
Observation:
Aggregations are performed on the primary, not the secondary. It looks as if the mongos is ignoring the readPreference or the driver is not sending it.
Change 1:
After browsing some code, there were indications that setting slave_okay may be required (the interctions between slave_okay and _use_master in collection.aggregate)
Observation:
No change in behaviour
Change 2:
Going deeper, I found the code from PYTHON-446 that only sets the read preference when connected to a mongos and readpreference is SECONDARY_PREFERRED if there are tags present.
Observation:
I short-circuited the check, and reads correctly come to the secondary.
The comment just before the check states:
- For maximum backwards compatibility, don't set $readPreference
- for SECONDARY_PREFERRED unless tags are in use. Just rely on
- the slaveOkay bit (set automatically if read preference is not
- PRIMARY), which has the same behavior.
This would be fine, but it appears that the slaveOkay bit is not respected (possibly in mongos?)(as I have ensured that it is set)
This behaviour is pretty unexpected, as is any reliance on the slave_okay param.
- depends on
-
SERVER-10594 slaveOk bit ignored for unsharded aggregate
- Closed