[JAVA-766] DBCollection.setReadReference() has no effect Created: 21/Feb/13  Updated: 21/Feb/13  Resolved: 21/Feb/13

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

Type: Bug Priority: Major - P3
Reporter: Yibing Shi Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Server: MongoDB 2.2.3 x64 version running on CentOS 6.3
Client: Sun JDK 1.6.0_31 x64 versuion, running on CentOS 6.3


Issue Links:
Duplicate
duplicates JAVA-705 Query commands like aggregate and map... Closed

 Description   

I have a sharded MongoDB cluster which has 2 shards. Each shard has 1 primary node, 1 secondary node and 1 arbiter. The mongos runs on one of the cluster machines.
I use the following codes to connec to mongos:
Mongo mongo = new Mongo(args[0]);
DB emData = mongo.getDB(args[1]);
DBCollection publicationMonth = emData.getCollection(args[2]);
publicationMonth.setReadPreference(ReadPreference.secondary());
However, when I execute an aggregation on the "publicationMonth" collection, only the primary nodes are busy to execute the query while the secondary nodes sitting there idle.

If I modify above codes a little bit to:
Mongo mongo = new Mongo(args[0]);
mongo.setReadReference(ReadPreference.secondary());
DB emData = mongo.getDB(args[1]);
DBCollection publicationMonth = emData.getCollection(args[2]);
secondary nodes will execute the aggregation query instead of primary nodes.



 Comments   
Comment by Yibing Shi [ 21/Feb/13 ]

Sorry for not finding the duplicated topic! I did some search before reporting but neglected JAVA-705.

Comment by Jeffrey Yemin [ 21/Feb/13 ]

Thanks for the report. I'm linking it to a previous report of the same issue and closing this one out. Please watch JAVA-705 for progress.

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