Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
2.9.0
-
None
-
2.9.0-RC2 drivers, CentOS5, Mongo v. 2.0.6
Description
My java program performs some queries which fail only when the read preference is set to nearest (either through a mongo uri with readPreference=nearest, or by setting it in the Java code). The cluster I'm using has 4 replica sets, each one with a primary and a secondary. The query I'm trying to perform is similar to:
db.mycollection.find("_id", "JC &|1100222232010210")
public byte[] searchEquals(String table, String key) {
|
DBCollection col = db.getCollection(table);
|
DBObject o = new BasicDBObject("_id", key);
|
DBObject oo = col.findOne(o, id);
|
if(oo==null) throw new RuntimeException("Mongo searching "+table+" for =="+key+" resulted in nothing.");
|
return ((String)oo.get("_id")).getBytes();
|
}
|
When running the method when the read preference is set to nearest, it throws the exception after running a few queries successfully. When running without read preference set to nearest, it doesn't throw the error.