-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
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!
- related to
-
JAVA-404 Allow inline M/R w/SlaveOk go to secondaries
- Closed