[JAVA-535] DB.getCollectionNames() fails when connected to a secondary server even if ReadPreference is SECONDARY Created: 08/Mar/12  Updated: 14/Aug/12  Resolved: 14/May/12

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.8.0

Type: Bug Priority: Major - P3
Reporter: Robert Miyashiro Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates JAVA-497 ReadPrefs ignored for commands Closed

 Description   

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.



 Comments   
Comment by Jeffrey Yemin [ 18/Jun/12 ]

Closing for 2.8.0 release.

Comment by auto [ 14/May/12 ]

Author:

{u'login': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-535: Respecting read preference on DB for DB.getCollectionNames
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/1d906071f8b38063ed1d26c99891cc1212faf7da

Comment by Jeffrey Yemin [ 14/May/12 ]

This is actually a separate bug from the one it was resolved as a duplicate of, since getCollectionNames is not implemented as a command.

Comment by Jeffrey Yemin [ 12/Mar/12 ]

This is the same issue as JAVA-497, so I'm going to close as a duplicate. Please track progress on the duplicated issue.

Comment by Robert Miyashiro [ 08/Mar/12 ]

Yes, a URI that looks like this: mongodb://secondary.foo.com:12345
We're also using the MongoHolder.connect() method if that's relevant.

Comment by Scott Hernandez (Inactive) [ 08/Mar/12 ]

How are you connecting? Just with the single address of a secondary?

Comment by Robert Miyashiro [ 08/Mar/12 ]

We're using 2.7.3

Comment by Scott Hernandez (Inactive) [ 08/Mar/12 ]

What version are you using? If you aren't using the latest versoin please do, there was a bug in 2.7.0/1 I believe.

Generated at Thu Feb 08 08:52:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.