Problem reading from primary using Java driver and TaggedReadPreference

17 views
Skip to first unread message

Bryan Hunt

unread,
Nov 26, 2011, 2:59:54 PM11/26/11
to mongodb-user
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 ('{ "locale" : "sc"}'
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)

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" : {
"locale" : "sc"
}
},
{
"_id" : 1,
"host" : "localhost:27021",
"tags" : {
"locale" : "in"
}
},
{
"_id" : 2,
"host" : "localhost:27022",
"tags" : {
"locale" : "de"
}
}
]
}

Eliot Horowitz

unread,
Nov 26, 2011, 11:19:29 PM11/26/11
to mongod...@googlegroups.com
This is using master from github?
Can you open a case @ http://jira.mongodb.org/

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Bryan Hunt

unread,
Nov 27, 2011, 12:05:03 AM11/27/11
to mongodb-user
I'm using the 2.7.2 release of the Java driver. I opened a bug as
requested. https://jira.mongodb.org/browse/JAVA-477


On Nov 26, 10:19 pm, Eliot Horowitz <el...@10gen.com> wrote:
> This is using master from github?

> Can you open a case @http://jira.mongodb.org/

Reply all
Reply to author
Forward
0 new messages