diff options
author | Moustafa Maher <m.maher@10gen.com> | 2021-08-26 19:23:39 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-30 19:11:31 +0000 |
commit | 8a5c1f52a77bc92320c90ecbe5424e841874296e (patch) | |
tree | 85fab761d52c8a93aeeac395dd4b2fc539071c9a | |
parent | 0dd96157fb1fffc8eefe6be4b26aff9805bfbfac (diff) | |
download | mongo-8a5c1f52a77bc92320c90ecbe5424e841874296e.tar.gz |
SERVER-34938 Secondary slowdown or hang due to content pinned in cache by single oplog batchr4.2.16-rc0r4.2.16
-rw-r--r-- | src/mongo/db/repl/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier.cpp | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index 39ecc27ce01..41040f145ba 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -677,6 +677,7 @@ env.Library( '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/executor/task_executor_interface', '$BUILD_DIR/mongo/util/concurrency/thread_pool', + '$BUILD_DIR/mongo/util/processinfo', 'oplog_entry', ], LIBDEPS_PRIVATE=[ diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp index 34be41fda71..92b2f84db27 100644 --- a/src/mongo/db/repl/oplog_applier.cpp +++ b/src/mongo/db/repl/oplog_applier.cpp @@ -40,6 +40,7 @@ #include "mongo/db/repl/repl_server_parameters_gen.h" #include "mongo/db/repl/sync_tail.h" #include "mongo/util/log.h" +#include "mongo/util/processinfo.h" #include "mongo/util/time_support.h" namespace mongo { @@ -53,7 +54,12 @@ std::unique_ptr<ThreadPool> OplogApplier::makeWriterPool() { severe() << "replWriterMinThreadCount must be less than or equal to replWriterThreadCount."; fassertFailedNoTrace(5605400); } - return makeWriterPool(replWriterThreadCount); + + // Reduce content pinned in cache by single oplog batch on small machines by reducing the number + // of threads of ReplWriter to reduce the number of concurrent open WT transactions. + auto numberOfThreads = + std::min(replWriterThreadCount, 2 * static_cast<int>(ProcessInfo::getNumAvailableCores())); + return makeWriterPool(numberOfThreads); } // static |