-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.7.2
-
Component/s: Cluster Management
-
None
-
Environment:All components running on OS X 10.7.2. MongoDB version 2.0.1. Java driver version 2.7.2.
I'm trying to use the TaggedReadPreference with the Java driver when
reading from a replica set. It seems to work as long as I specify a
secondary tag. When I specify the primary tag, I get the following
exception:
com.mongodb.MongoException: Could not find any valid secondaries with
the supplied tags ('
'
at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:358)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:212)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
at com.mongodb.DBCollection.findOne(DBCollection.java:647)
at com.mongodb.DBCollection.findOne(DBCollection.java:626)
I also tested reading from the secondary and killing the primary. When
the secondary is elected the primary, the read fails with the same
exception above (just with a different locale).
My code looks like:
HashMap<String, String> tags = new HashMap<String, String>(1);
tags.put("locale", "sc");
...
dbCollection.setReadPreference(new
ReadPreference.TaggedReadPreference(tags));
My replica set is configured as:
PRIMARY> rs.conf()
{
"_id" : "test",
"version" : 3,
"members" : [
{
"_id" : 0,
"host" : "localhost:27020",
"priority" : 2,
"tags" :
},
{
"_id" : 1,
"host" : "localhost:27021",
"tags" :
},
{
"_id" : 2,
"host" : "localhost:27022",
"tags" :
}
]
- duplicates
-
JAVA-474 Enhance read preference support
- Closed