summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorWaley Chen <waleycz@gmail.com>2016-09-13 16:10:04 -0400
committerWaley Chen <waleycz@gmail.com>2016-09-13 17:54:11 -0400
commit955cf8c998a60a8c2a2493dd428dd3d763e90259 (patch)
tree9e6253c35b752b6f853454cfb4a47acdb5cf77dd /src/mongo/shell
parent4f211b037feac1d4c80d65df5a0fae12fcac1e4c (diff)
downloadmongo-955cf8c998a60a8c2a2493dd428dd3d763e90259.tar.gz
SERVER-22688 Provide a setParameter and shell option to control the js heap limit
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/dbshell.cpp1
-rw-r--r--src/mongo/shell/shell_options.cpp13
-rw-r--r--src/mongo/shell/shell_options.h2
3 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 5df9fc23679..768c8558efd 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -708,6 +708,7 @@ int _main(int argc, char* argv[], char** envp) {
mongo::ScriptEngine::setConnectCallback(mongo::shell_utils::onConnect);
mongo::ScriptEngine::setup();
+ mongo::globalScriptEngine->setJSHeapMBLimit(shellGlobalParams.jsHeapMBLimit);
mongo::globalScriptEngine->setScopeInitCallback(mongo::shell_utils::initScope);
mongo::globalScriptEngine->enableJIT(!shellGlobalParams.nojit);
mongo::globalScriptEngine->enableJavaScriptProtection(shellGlobalParams.javascriptProtection);
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 1b378836c35..324ad87fa3d 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -200,6 +200,9 @@ Status addMongoShellOptions(moe::OptionSection* options) {
if (!ret.isOK())
return ret;
+ options->addOptionChaining(
+ "jsHeapMBLimit", "jsHeapMBLimit", moe::Int, "set the js scope's heap size limit");
+
return Status::OK();
}
@@ -370,6 +373,16 @@ Status storeMongoShellOptions(const moe::Environment& params,
}
}
+ if (params.count("jsHeapMBLimit")) {
+ int jsHeapMBLimit = params["jsHeapMBLimit"].as<int>();
+ if (jsHeapMBLimit <= 0) {
+ StringBuilder sb;
+ sb << "ERROR: \"jsHeapMBLimit\" needs to be greater than 0";
+ return Status(ErrorCodes::BadValue, sb.str());
+ }
+ shellGlobalParams.jsHeapMBLimit = jsHeapMBLimit;
+ }
+
if (shellGlobalParams.url == "*") {
StringBuilder sb;
sb << "ERROR: "
diff --git a/src/mongo/shell/shell_options.h b/src/mongo/shell/shell_options.h
index 62191bfb0c9..296567025e3 100644
--- a/src/mongo/shell/shell_options.h
+++ b/src/mongo/shell/shell_options.h
@@ -73,6 +73,8 @@ struct ShellGlobalParams {
std::string readMode = "compatibility";
boost::optional<rpc::ProtocolSet> rpcProtocols = boost::none;
+
+ int jsHeapMBLimit = 0;
};
extern ShellGlobalParams shellGlobalParams;