diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2019-07-10 09:07:10 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2019-07-12 12:46:07 -0400 |
commit | 6fda68e42adc09210537c8f3dcc7e811787960d7 (patch) | |
tree | d17cf270b97c36c996adf71fb388929233cd3c82 | |
parent | e42ecd228cd8167a5ff4b5f52bec4b4b0504dfd7 (diff) | |
download | mongo-6fda68e42adc09210537c8f3dcc7e811787960d7.tar.gz |
SERVER-42134 Deprecate certain mapReduce parameters
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/commands/mr_common.cpp | 14 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_map_reduce.cpp | 7 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 74ec1dbfdbe..244acfbd221 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -72,6 +72,7 @@ #include "mongo/s/stale_exception.h" #include "mongo/scripting/engine.h" #include "mongo/stdx/mutex.h" +#include "mongo/util/debug_util.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" @@ -92,6 +93,8 @@ namespace dps = ::mongo::dotted_path_support; namespace mr { namespace { +Rarely mapParamsDeprecationSampler; // Used to occasionally log deprecation messages. + /** * Runs a count against the namespace specified by 'ns'. If the caller holds the global write lock, * then this function does not acquire any additional locks. @@ -456,8 +459,14 @@ Config::Config(const string& _dbname, const BSONObj& cmdObj) { if (cmdObj["finalize"].type() && cmdObj["finalize"].trueValue()) finalizer.reset(new JSFinalizer(cmdObj["finalize"])); - if (cmdObj["mapparams"].type() == Array) { - mapParams = cmdObj["mapparams"].embeddedObjectUserCheck().getOwned(); + // DEPRECATED + if (auto mapParamsElem = cmdObj["mapparams"]) { + if (mapParamsDeprecationSampler.tick()) { + warning() << "The mapparams option to MapReduce is deprecated."; + } + if (mapParamsElem.type() == Array) { + mapParams = mapParamsElem.embeddedObjectUserCheck().getOwned(); + } } } diff --git a/src/mongo/db/commands/mr_common.cpp b/src/mongo/db/commands/mr_common.cpp index ad82a5d190b..90ebddcd6e6 100644 --- a/src/mongo/db/commands/mr_common.cpp +++ b/src/mongo/db/commands/mr_common.cpp @@ -27,6 +27,8 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand + #include "mongo/db/commands/mr_common.h" #include <string> @@ -38,11 +40,17 @@ #include "mongo/db/catalog/document_validation.h" #include "mongo/db/commands.h" #include "mongo/db/jsobj.h" +#include "mongo/util/log.h" #include "mongo/util/str.h" namespace mongo { namespace mr { + +namespace { +Rarely nonAtomicDeprecationSampler; // Used to occasionally log deprecation messages. +} // namespace + OutputOptions parseOutputOptions(const std::string& dbname, const BSONObj& cmdObj) { OutputOptions outputOptions; @@ -76,14 +84,16 @@ OutputOptions parseOutputOptions(const std::string& dbname, const BSONObj& cmdOb if (o.hasElement("db")) { outputOptions.outDB = o["db"].String(); } - if (o.hasElement("nonAtomic")) { outputOptions.outNonAtomic = o["nonAtomic"].Bool(); - if (outputOptions.outNonAtomic) + if (outputOptions.outNonAtomic) { uassert(15895, "nonAtomic option cannot be used with this output type", (outputOptions.outType == OutputType::kReduce || outputOptions.outType == OutputType::kMerge)); + } else if (nonAtomicDeprecationSampler.tick()) { + warning() << "Setting out.nonAtomic to false in MapReduce is deprecated."; + } } } else { uasserted(13606, "'out' has to be a string or an object"); diff --git a/src/mongo/s/commands/cluster_map_reduce.cpp b/src/mongo/s/commands/cluster_map_reduce.cpp index dd74ef1e6c7..af3d8274601 100644 --- a/src/mongo/s/commands/cluster_map_reduce.cpp +++ b/src/mongo/s/commands/cluster_map_reduce.cpp @@ -52,6 +52,10 @@ namespace mongo { const Milliseconds kNoDistLockTimeout(-1); AtomicWord<unsigned> jobNumber; +namespace { +// Used to rarely log deprecation messages. +Rarely shardedOutputDeprecationSampler; +} // namespace /** * Generates a unique name for the temporary M/R output collection. @@ -221,6 +225,9 @@ bool runMapReduce(OperationContext* opCtx, if (outElmt.type() == Object) { // Check if there is a custom output BSONObj customOut = outElmt.embeddedObject(); + if (customOut.hasField("sharded") && shardedOutputDeprecationSampler.tick()) { + warning() << "the out.sharded option to mapReduce is deprecated."; + } shardedOutput = customOut.getBoolField("sharded"); if (customOut.hasField("inline")) { |