summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Evans <jacob.evans@mongodb.com>2019-12-11 21:33:49 +0000
committerevergreen <evergreen@mongodb.com>2019-12-11 21:33:49 +0000
commit57acc8b666b8c9dfc34eaf03c226ab26ac225781 (patch)
tree1a0971f0cce77fc5178fc48952770dc164818b22 /src
parent3da6513067131a50323f3388b8dc2918da885732 (diff)
downloadmongo-57acc8b666b8c9dfc34eaf03c226ab26ac225781.tar.gz
SERVER-44475 Remove Query Knob
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/map_reduce_command.cpp6
-rw-r--r--src/mongo/db/commands/map_reduce_command_base.h23
-rw-r--r--src/mongo/db/commands/mr_test.cpp4
-rw-r--r--src/mongo/db/query/query_knobs.idl7
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_agg.cpp11
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_cmd.cpp9
7 files changed, 39 insertions, 22 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 3bdfb73e08d..1e1b927a553 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -520,6 +520,7 @@ env.Library(
'$BUILD_DIR/mongo/db/db_raii',
'$BUILD_DIR/mongo/db/index/index_access_methods',
'$BUILD_DIR/mongo/db/pipeline/mongo_process_interface',
+ '$BUILD_DIR/mongo/db/pipeline/process_interface_factory_mongod',
'$BUILD_DIR/mongo/db/query_exec',
'$BUILD_DIR/mongo/db/query/map_reduce_output_format',
'$BUILD_DIR/mongo/idl/idl_parser',
diff --git a/src/mongo/db/commands/map_reduce_command.cpp b/src/mongo/db/commands/map_reduce_command.cpp
index c605affd325..5cae9c1e228 100644
--- a/src/mongo/db/commands/map_reduce_command.cpp
+++ b/src/mongo/db/commands/map_reduce_command.cpp
@@ -78,11 +78,9 @@ private:
// Execute the mapReduce as an aggregation pipeline only if fully upgraded to 4.4, since
// a 4.2 mongos in a mixed version cluster expects a fundamentally different response that
// is not supported by the aggregation equivalent.
- if (internalQueryUseAggMapReduce.load() &&
- serverGlobalParams.featureCompatibility.getVersion() ==
- ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) {
+ if (serverGlobalParams.featureCompatibility.getVersion() ==
+ ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44)
return map_reduce_agg::runAggregationMapReduce(opCtx, cmd, result, boost::none);
- }
return mr::runMapReduce(opCtx, dbname, cmd, errmsg, result);
}
} mapReduceCommand;
diff --git a/src/mongo/db/commands/map_reduce_command_base.h b/src/mongo/db/commands/map_reduce_command_base.h
index 5166cdec327..1595242b4b4 100644
--- a/src/mongo/db/commands/map_reduce_command_base.h
+++ b/src/mongo/db/commands/map_reduce_command_base.h
@@ -44,6 +44,24 @@ public:
"details.";
}
+ /**
+ * The mapReduce command supports only 'local' and 'available' readConcern levels.
+ * For aggregation-based mapReduce there are no known restrictions to broader support, but work
+ * would need to be done confirm support for both command and aggregation stages as is done for
+ * the aggregate command.
+ */
+ virtual ReadConcernSupportResult supportsReadConcern(const BSONObj& cmdObj,
+ repl::ReadConcernLevel level) const {
+ static const Status kReadConcernNotSupported{ErrorCodes::InvalidOptions,
+ "read concern not supported"};
+ static const Status kDefaultReadConcernNotPermitted{ErrorCodes::InvalidOptions,
+ "default read concern not permitted"};
+ return {{level != repl::ReadConcernLevel::kLocalReadConcern &&
+ level != repl::ReadConcernLevel::kAvailableReadConcern,
+ kReadConcernNotSupported},
+ {kDefaultReadConcernNotPermitted}};
+ }
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return map_reduce_common::mrSupportsWriteConcern(cmd);
}
@@ -74,9 +92,8 @@ public:
const OpMsgRequest& request,
ExplainOptions::Verbosity verbosity,
rpc::ReplyBuilderInterface* result) const override {
- if (internalQueryUseAggMapReduce.load() &&
- serverGlobalParams.featureCompatibility.getVersion() ==
- ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) {
+ if (serverGlobalParams.featureCompatibility.getVersion() ==
+ ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) {
auto builder = result->getBodyBuilder();
auto explain = boost::make_optional(verbosity);
try {
diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp
index c65f492893d..f7a05c77103 100644
--- a/src/mongo/db/commands/mr_test.cpp
+++ b/src/mongo/db/commands/mr_test.cpp
@@ -341,7 +341,9 @@ void MapReduceOpObserver::onStartIndexBuild(OperationContext* opCtx,
const UUID& indexBuildUUID,
const std::vector<BSONObj>& indexes,
bool fromMigrate) {
- indexesCreated = indexes;
+ for (auto&& obj : indexes) {
+ indexesCreated.push_back(obj.getOwned());
+ }
}
void MapReduceOpObserver::onInserts(OperationContext* opCtx,
diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl
index 8609e832f8f..09824ee3922 100644
--- a/src/mongo/db/query/query_knobs.idl
+++ b/src/mongo/db/query/query_knobs.idl
@@ -298,13 +298,6 @@ server_parameters:
cpp_vartype: AtomicWord<bool>
default: false
- internalQueryUseAggMapReduce:
- description: "If true runs mapReduce in a pipeline instead of the mapReduce command."
- set_at: [ startup, runtime ]
- cpp_varname: "internalQueryUseAggMapReduce"
- cpp_vartype: AtomicWord<bool>
- default: false
-
internalQueryMaxJsEmitBytes:
description: "Limits the vector of values emitted from a single document's call to JsEmit to the
given size in bytes."
diff --git a/src/mongo/s/commands/cluster_map_reduce_agg.cpp b/src/mongo/s/commands/cluster_map_reduce_agg.cpp
index 66755ea7d16..38caba355de 100644
--- a/src/mongo/s/commands/cluster_map_reduce_agg.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_agg.cpp
@@ -34,6 +34,7 @@
#include "mongo/bson/util/bson_extract.h"
#include "mongo/client/connpool.h"
#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/map_reduce_agg.h"
@@ -113,6 +114,15 @@ Document serializeToCommand(BSONObj originalCmd, const MapReduce& parsedMr, Pipe
translatedCmd[AggregationRequest::kRuntimeConstants] =
Value(pipeline->getContext()->getRuntimeConstants().toBSON());
+ if (shouldBypassDocumentValidationForCommand(originalCmd)) {
+ translatedCmd[bypassDocumentValidationCommandOption()] = Value(true);
+ }
+
+ if (originalCmd[AggregationRequest::kCollationName]) {
+ translatedCmd[AggregationRequest::kCollationName] =
+ Value(originalCmd[AggregationRequest::kCollationName]);
+ }
+
// TODO SERVER-44884: We set this flag to indicate that the shards should always use the new
// upsert mechanism when executing relevant $merge modes. After branching for 4.5, supported
// upgrade versions will all use the new mechanism, and we can remove this flag.
@@ -224,7 +234,6 @@ bool runAggregationMapReduce(OperationContext* opCtx,
if (verbosity) {
map_reduce_output_format::appendExplainResponse(result, aggResults);
} else if (parsedMr.getOutOptions().getOutputType() == OutputType::InMemory) {
- // TODO SERVER-43290: Add support for cluster MapReduce statistics.
// If the inline results could not fit into a single batch, then kill the remote
// operation(s) and return an error since mapReduce does not support a cursor-style
// response.
diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
index bc9af46c0bb..ebf17d6c8c4 100644
--- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
@@ -57,14 +57,11 @@ public:
}
bool _runImpl(OperationContext* opCtx,
- const std::string& dbname,
+ const std::string&,
const BSONObj& cmd,
- std::string& errmsg,
+ std::string&,
BSONObjBuilder& result) final {
- if (internalQueryUseAggMapReduce.load()) {
- return runAggregationMapReduce(opCtx, cmd, result, boost::none);
- }
- return runMapReduce(opCtx, dbname, applyReadWriteConcern(opCtx, this, cmd), errmsg, result);
+ return runAggregationMapReduce(opCtx, cmd, result, boost::none);
}
} clusterMapReduceCommand;