summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojislav Stojkovic <vojislav.stojkovic@mongodb.com>2021-09-21 10:59:15 -0700
committerVojislav Stojkovic <vojislav.stojkovic@mongodb.com>2021-09-22 13:59:12 -0700
commit2bc0c12afc214d31d0c4bbbdf27df46c3e2050c3 (patch)
tree0d8be4399992793846bf6822e92fe3c288da027c
parentb20ce276cce24c81cbe75ca56ad5075d6c1c88c4 (diff)
downloadmongo-server-51233.tar.gz
SERVER-51233 Warn on startup if vm.max_map_count is too lowserver-51233
-rw-r--r--src/mongo/db/startup_warnings_mongod.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/db/startup_warnings_mongod.cpp b/src/mongo/db/startup_warnings_mongod.cpp
index bcbdd49355a..80fda5e69f1 100644
--- a/src/mongo/db/startup_warnings_mongod.cpp
+++ b/src/mongo/db/startup_warnings_mongod.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/startup_warnings_common.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/logv2/log.h"
+#include "mongo/transport/service_entry_point.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/str.h"
#include "mongo/util/version.h"
@@ -281,6 +282,29 @@ void logMongodStartupWarnings(const StorageGlobalParams& storageParams,
"Failed to read " TRANSPARENT_HUGE_PAGES_DIR "/defrag",
"error"_attr = transparentHugePagesDefragResult.getStatus().reason());
}
+
+ // Check if vm.max_map_count is high enough, as per SERVER-51233
+ {
+ size_t maxConns = svcCtx->getServiceEntryPoint()->maxOpenSessions();
+ size_t requiredMapCount = 2 * maxConns;
+
+ std::fstream f("/proc/sys/vm/max_map_count", ios_base::in);
+ size_t val;
+ f >> val;
+
+ if (val < requiredMapCount) {
+ LOGV2_WARNING_OPTIONS(5123300,
+ {logv2::LogTag::kStartupWarnings},
+ "** WARNING: Maximum number of memory map areas per process is "
+ "too low. Current value of vm.max_map_count is {currentValue}, "
+ "recommended minimum is {recommendedMinimum} for currently "
+ "configured maximum connections ({maxConns})",
+ "vm.max_map_count is too low",
+ "currentValue"_attr = val,
+ "recommendedMinimum"_attr = requiredMapCount,
+ "maxConns"_attr = maxConns);
+ }
+ }
#endif // __linux__
#ifndef _WIN32