summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/mr_common.cpp
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2019-11-01 21:47:44 +0000
committerevergreen <evergreen@mongodb.com>2019-11-01 21:47:44 +0000
commite5340534df81238e454ce7d3afbb7883115f2c53 (patch)
treef2176e41aa558a45af9ef576329ad7abf4e8702a /src/mongo/db/commands/mr_common.cpp
parent8191b9a55df49629d7f8aec22a4e9c9414e9e914 (diff)
downloadmongo-e5340534df81238e454ce7d3afbb7883115f2c53.tar.gz
SERVER-43578 M/R Agg: Reject mapreduce command sent to mongos which is expected to drop and re-shard the output collection
Diffstat (limited to 'src/mongo/db/commands/mr_common.cpp')
-rw-r--r--src/mongo/db/commands/mr_common.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/commands/mr_common.cpp b/src/mongo/db/commands/mr_common.cpp
index 8eece3727a0..16269873593 100644
--- a/src/mongo/db/commands/mr_common.cpp
+++ b/src/mongo/db/commands/mr_common.cpp
@@ -331,6 +331,14 @@ std::unique_ptr<Pipeline, PipelineDeleter> translateFromMR(
shardKey == std::set<FieldPath>{FieldPath("_id"s)});
}
+ // If sharded option is set to true and the replace action is specified, verify that this isn't
+ // running on mongos.
+ if (outType == OutputType::Replace && parsedMr.getOutOptions().isSharded()) {
+ uassert(31327,
+ "Cannot replace output collection when specifying sharded: true",
+ !expCtx->inMongos);
+ }
+
// TODO: It would be good to figure out what kind of errors this would produce in the Status.
// It would be better not to produce something incomprehensible out of an internal translation.
auto pipeline = uassertStatusOK(Pipeline::create(