summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2020-01-20 05:00:36 +0000
committerA. Jesse Jiryu Davis <jesse@mongodb.com>2020-01-27 15:40:42 -0500
commit3767b47951db572be50dee736663f5d9028750af (patch)
tree7f5443ea4913fc15bf70ed747357c8bd48742d4a
parenta8c79b41242dde27db00a60a17fe0d60f5fa3c8a (diff)
downloadmongo-3767b47951db572be50dee736663f5d9028750af.tar.gz
SERVER-45549 make aggregate command on mongos always send RWC (and use RWC defaults)
-rw-r--r--jstests/sharding/read_write_concern_defaults_application.js3
-rw-r--r--src/mongo/db/pipeline/sharded_agg_helpers.cpp28
2 files changed, 17 insertions, 14 deletions
diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js
index 5e773668db6..8b867e6297b 100644
--- a/jstests/sharding/read_write_concern_defaults_application.js
+++ b/jstests/sharding/read_write_concern_defaults_application.js
@@ -147,9 +147,6 @@ let testCases = {
command: {aggregate: coll, pipeline: [{$match: {x: 1}}, {$out: "out"}], cursor: {}},
checkReadConcern: true,
checkWriteConcern: true,
- // TODO SERVER-45549: Remove the following line once RWC defaults are correctly being
- // applied on mongos.
- target: "replset",
},
appendOplogNote: {
command: {appendOplogNote: 1, data: {foo: 1}},
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
index e305217ed2d..fedea813ff1 100644
--- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp
+++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
@@ -596,15 +596,18 @@ DispatchShardPipelineResults dispatchShardPipeline(
}
// Generate the command object for the targeted shards.
- BSONObj targetedCommand = splitPipeline
- ? createCommandForTargetedShards(
- expCtx, serializedCommand, *splitPipeline, exchangeSpec, true)
- : createPassthroughCommandForShard(expCtx,
- serializedCommand,
- expCtx->explain,
- expCtx->getRuntimeConstants(),
- pipeline.get(),
- collationObj);
+ BSONObj targetedCommand = applyReadWriteConcern(
+ opCtx,
+ true, /* appendRC */
+ !expCtx->explain, /* appendWC */
+ splitPipeline ? createCommandForTargetedShards(
+ expCtx, serializedCommand, *splitPipeline, exchangeSpec, true)
+ : createPassthroughCommandForShard(expCtx,
+ serializedCommand,
+ expCtx->explain,
+ expCtx->getRuntimeConstants(),
+ pipeline.get(),
+ collationObj));
// A $changeStream pipeline must run on all shards, and will also open an extra cursor on the
// config server in order to monitor for new shards. To guarantee that we do not miss any
@@ -1082,9 +1085,12 @@ Status runPipelineOnPrimaryShard(const boost::intrusive_ptr<ExpressionContext>&
// Format the command for the shard. This adds the 'fromMongos' field, wraps the command as an
// explain if necessary, and rewrites the result into a format safe to forward to shards.
- BSONObj cmdObj =
+ BSONObj cmdObj = applyReadWriteConcern(
+ opCtx,
+ true, /* appendRC */
+ !explain, /* appendWC */
CommandHelpers::filterCommandRequestForPassthrough(createPassthroughCommandForShard(
- expCtx, serializedCommand, explain, boost::none, nullptr, BSONObj()));
+ expCtx, serializedCommand, explain, boost::none, nullptr, BSONObj())));
const auto shardId = dbInfo.primary()->getId();
const auto cmdObjWithShardVersion = (shardId != ShardRegistry::kConfigServerShardId)