diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2019-08-20 15:52:59 -0400 |
---|---|---|
committer | Ted Tuckman <ted.tuckman@mongodb.com> | 2019-08-23 09:22:31 -0400 |
commit | 7727804534b7c12dbe4c624b7ac24f566a353543 (patch) | |
tree | 51d1760a78649e7ddfd9ffe67966724957d7b629 | |
parent | 3d31cb6e94b857d9a0c8907689e65aaacbb4023d (diff) | |
download | mongo-7727804534b7c12dbe4c624b7ac24f566a353543.tar.gz |
SERVER-42888 Deprecate CodeWScope in MapReduce
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/mr.h | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 0e6d4baa02b..75dde5374ad 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -231,8 +231,12 @@ JSFunction::JSFunction(const std::string& type, const BSONElement& e) { _type = type; _code = e._asCode(); - if (e.type() == CodeWScope) + if (e.type() == CodeWScope) { + if (_sampler.tick()) + warning() << "Use of CodeWScope with MapReduce is deprecated. Prefer putting all scope " + "variables in the scope parameter of the MapReduce command"; _wantedScope = e.codeWScopeObject(); + } } void JSFunction::init(State* state) { diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h index aab8f011d09..70cdaebcbd5 100644 --- a/src/mongo/db/commands/mr.h +++ b/src/mongo/db/commands/mr.h @@ -39,6 +39,7 @@ #include "mongo/db/namespace_string.h" #include "mongo/platform/atomic_word.h" #include "mongo/scripting/engine.h" +#include "mongo/util/debug_util.h" namespace mongo { @@ -129,6 +130,8 @@ private: std::string _type; std::string _code; // actual javascript code BSONObj _wantedScope; // this is for CodeWScope + // Used to log occassional deprecation warnings when CodeWScope is used in MapReduce. + Rarely _sampler; Scope* _scope; // this is not owned by us, and might be shared ScriptingFunction _func; |