readPreference=nearest fails sometimes

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.9.0
    • Component/s: API
    • None
    • Environment:
      2.9.0-RC2 drivers, CentOS5, Mongo v. 2.0.6
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Unassigned
            Reporter:
            Paul Mahon
            None
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: