summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoustafa Maher <m.maher@10gen.com>2021-08-30 18:40:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-30 21:37:24 +0000
commitd47b151b55f286546e7c7c98888ae0577856ca20 (patch)
tree54643132d30f79c0411945e90a2f7863239e695a
parentb281c0c680b381b50e497e9e7636f73498a00287 (diff)
downloadmongo-d47b151b55f286546e7c7c98888ae0577856ca20.tar.gz
SERVER-34938 Secondary slowdown or hang due to content pinned in cache by single oplog batchr4.0.27-rc0r4.0.27
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/sync_tail.cpp9
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 2ecf6829075..d2ba2217e51 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -653,6 +653,7 @@ env.Library(
'$BUILD_DIR/mongo/db/storage/storage_options',
'$BUILD_DIR/mongo/util/concurrency/thread_pool',
'$BUILD_DIR/mongo/util/net/network',
+ '$BUILD_DIR/mongo/util/processinfo',
'initial_syncer',
'oplog',
'oplog_entry',
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 9f921bfb714..c4e9d0ff722 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -83,6 +83,7 @@
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/socket_exception.h"
+#include "mongo/util/processinfo.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
@@ -380,7 +381,13 @@ std::unique_ptr<ThreadPool> SyncTail::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);
}
std::unique_ptr<ThreadPool> SyncTail::makeWriterPool(int threadCount) {