As a follow up for SERVER-28450
enable causal consistency for:
aggregate command and the db.collection.aggregate() method
distinct command
count command
group command
parallelCollectionScan command
geoNear command
geoSearch command
mapReduce command
The check is done at
https://github.com/mongodb/mongo/blob/master/src/mongo/shell/mongo.js#L46
it should be changed to
var commandsToForceReadConcern = [ "count", "distinct", "find", "geoNear", "geoSearch", "group", "mapReduce", "parallelCollectionScan", ]; var forceReadConcern = Array.contains(commandsToForceReadConcern, cmdName); if (cmdName === "aggregate") { // Aggregate can be either a read or a write depending on whether it has a $out stage. // $out is required to be the last stage of the pipeline. var stages = obj.pipeline; const lastStage = stages && Array.isArray(stages) && (stages.length !== 0) ? stages[stages.length - 1] : undefined; const hasOut = lastStage && (typeof lastStage === 'object') && lastStage.hasOwnProperty('$out'); const hasExplain = obj.hasOwnProperty("explain"); if (!hasExplain && !hasOut) { forceReadConcern = true; } } return forceReadConcern;