From 1aa89ed63a35a7e7b898eefd3cc7bacbd40a89c3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 14 Nov 2018 04:20:46 +0300 Subject: [PATCH] Fixed code after review #3553 --- dbms/programs/server/Server.cpp | 31 +++++++++++-------------------- dbms/programs/server/config.xml | 6 ++++++ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/dbms/programs/server/Server.cpp b/dbms/programs/server/Server.cpp index c40962d5ebe..0937cf4b84a 100644 --- a/dbms/programs/server/Server.cpp +++ b/dbms/programs/server/Server.cpp @@ -131,39 +131,30 @@ int Server::main(const std::vector & /*args*/) } const auto memory_amount = getMemoryAmount(); - { /// After full config loaded + #if defined(__linux__) - if (config().getBool("mlock_executable", - false // TODO: uncomment after tests: -/* -#if NDEBUG - memory_amount > 16000000000 - ? true // Change me to true in future - : false // Dont mlock if we have less than 16G ram -#else - false -#endif -*/ - )) + /// After full config loaded + { + if (config().getBool("mlock_executable", false)) { if (hasLinuxCapability(CAP_IPC_LOCK)) { + LOG_TRACE(log, "Will mlockall to prevent executable memory from being paged out. It may take a few seconds."); if (0 != mlockall(MCL_CURRENT)) LOG_WARNING(log, "Failed mlockall: " + errnoToString()); else - LOG_TRACE(log, "Binary mlock'ed"); + LOG_TRACE(log, "The memory map of clickhouse executable has been mlock'ed"); } else { - LOG_INFO(log, "It looks like the process has no CAP_IPC_LOCK capability, binary mlock will be disabled." - " It could happen due to incorrect ClickHouse package installation." - " You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep /usr/bin/clickhouse'." - " Note that it will not work on 'nosuid' mounted filesystems."); - + LOG_INFO(log, "It looks like the process has no CAP_IPC_LOCK capability, binary mlock will be disabled." + " It could happen due to incorrect ClickHouse package installation." + " You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep /usr/bin/clickhouse'." + " Note that it will not work on 'nosuid' mounted filesystems."); } } -#endif } +#endif std::string path = getCanonicalPath(config().getString("path")); std::string default_database = config().getString("default_database", "default"); diff --git a/dbms/programs/server/config.xml b/dbms/programs/server/config.xml index e461d49d522..051f6f7fb2b 100644 --- a/dbms/programs/server/config.xml +++ b/dbms/programs/server/config.xml @@ -145,6 +145,12 @@ --> + + false +