-
Type:
Bug
-
Resolution: Done
-
Priority:
Critical - P2
-
Affects Version/s: None
-
Component/s: Query Operations
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Both queries and "query-like" commands require two things to enable proper application of a non-primary read preference:
- set slaveOk bit if slaveOk is set (deprecated) or ReadPreference.isSlaveOk().
- Wrap in $query and set $readPreference field (mongos only, and only if read preference is not primary or secondaryPreferred).
Example of an integration test that should pass:
class CountOperationSpecification { def 'should run on secondary'() { assumeTrue(isDiscoverableReplicaSet()) given: def find = new Find().readPreference(ReadPreference.secondary()) def countOperation = new CountOperation(getNamespace(), find, new DocumentCodec(), bufferProvider, session, true) when: int count = countOperation.execute() then: count == 0 } }