-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
I want to get the list of collections in my database as reported by a secondary member of my replica set. If I have a Mongo connection to that member, and I set the ReadPreference to secondary, I'm able to successfully make queries and perform other operations, but I cannot call DB.getCollectionNames(). I get the same "not talking to master and retries used up" error that happens when ReadPreference isn't set correctly. The issue appears to be here, where the ReadPreference isn't being used when querying the system.namespaces collection:
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/DB.java#L283
When using slaveOk() instead, this works as expected. My understanding is that setReadPreference(SECONDARY) is supposed to behave the same way.
- duplicates
-
JAVA-497 ReadPrefs ignored for commands
- Closed