Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-364

MapReduceOutput sometimes returns empty results in a replica set when SLAVE_OK=true

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.7
    • Affects Version/s: 2.6.1
    • Component/s: Cluster Management
    • None
    • Fully Compatible

      After debugging this, I found that the map-reduce output collection is written to the master, but if you connected to the replica set with SLAVE_OK=true, you may very well be reading from a slave node before the output collection has been synced there, which will indeed give you empty results.

      The workaround I put in my code is to ensure that the output collection never has the SLAVE_OK=true option, no matter what connection options were set. However, I suggest putting this in the MapReduceOutput code. This could be added to the constructor:

      _coll = db.getCollection( _collname );
      if (_coll != null) _coll.setOptions(_coll.getOptions() & ~Bytes.QUERYOPTION_SLAVEOK);

      I have tested similar code with my applications, and it has indeed made this bug go away!

            Assignee:
            antoine Antoine Girbal
            Reporter:
            tal.liron Tal Liron
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: