summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp6
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp8
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.h2
4 files changed, 12 insertions, 6 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
index 01aa0d3bbc1..fd16df07dcb 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
@@ -46,9 +46,9 @@ Status WiredTigerGlobalOptions::add(moe::OptionSection* options) {
// WiredTiger storage engine options
wiredTigerOptions.addOptionChaining("storage.wiredTiger.engineConfig.cacheSizeGB",
"wiredTigerCacheSizeGB",
- moe::Int,
+ moe::Double,
"maximum amount of memory to allocate for cache; "
- "defaults to 1/2 of physical RAM").validRange(1, 10000);
+ "defaults to 1/2 of physical RAM");
wiredTigerOptions.addOptionChaining(
"storage.wiredTiger.engineConfig.statisticsLogDelaySecs",
"wiredTigerStatisticsLogDelaySecs",
@@ -107,7 +107,7 @@ Status WiredTigerGlobalOptions::store(const moe::Environment& params,
// WiredTiger storage engine options
if (params.count("storage.wiredTiger.engineConfig.cacheSizeGB")) {
wiredTigerGlobalOptions.cacheSizeGB =
- params["storage.wiredTiger.engineConfig.cacheSizeGB"].as<int>();
+ params["storage.wiredTiger.engineConfig.cacheSizeGB"].as<double>();
}
if (params.count("storage.syncPeriodSecs")) {
wiredTigerGlobalOptions.checkpointDelaySecs =
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h
index 9e2307ff0fa..7d92c2fe986 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h
@@ -50,7 +50,7 @@ public:
Status add(moe::OptionSection* options);
Status store(const moe::Environment& params, const std::vector<std::string>& args);
- size_t cacheSizeGB;
+ double cacheSizeGB;
size_t checkpointDelaySecs;
size_t statisticsLogDelaySecs;
std::string journalCompressor;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
index 4d493077a3b..a3f6f5e8a95 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
@@ -318,8 +318,9 @@ int64_t WiredTigerUtil::getIdentSize(WT_SESSION* s, const std::string& uri) {
return result.getValue();
}
-size_t WiredTigerUtil::getCacheSizeMB(int requestedCacheSizeGB) {
+size_t WiredTigerUtil::getCacheSizeMB(double requestedCacheSizeGB) {
double cacheSizeMB;
+ const double kMaxSizeCacheMB = 10 * 1000 * 1000;
if (requestedCacheSizeGB == 0) {
// Choose a reasonable amount of cache when not explicitly specified by user.
// Set a minimum of 256MB, otherwise use 50% of available memory over 1GB.
@@ -329,6 +330,11 @@ size_t WiredTigerUtil::getCacheSizeMB(int requestedCacheSizeGB) {
} else {
cacheSizeMB = 1024 * requestedCacheSizeGB;
}
+ if (cacheSizeMB > kMaxSizeCacheMB) {
+ log() << "Requested cache size: " << cacheSizeMB << "MB exceeds max; setting to "
+ << kMaxSizeCacheMB << "MB";
+ cacheSizeMB = kMaxSizeCacheMB;
+ }
return static_cast<size_t>(cacheSizeMB);
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
index 6f12bd54531..6227ae7852d 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
@@ -180,7 +180,7 @@ public:
* Return amount of memory to use for the WiredTiger cache based on either the startup
* option chosen or the amount of available memory on the host.
*/
- static size_t getCacheSizeMB(int requestedCacheSizeGB);
+ static size_t getCacheSizeMB(double requestedCacheSizeGB);
/**
* Returns a WT_EVENT_HANDER with MongoDB's default handlers.