Skip to content

Commit 8d1baf5

Browse files
Adding a max thread count to protect the db on hosts with a lot of cpus
1 parent 93ff5be commit 8d1baf5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

MongoBackup/Methods/Dumper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,15 @@ def wait(self):
6767
raise Exception, "Not all mongodump threads completed successfully!", None
6868

6969
def run(self):
70-
# decide how many parallel dump workers to use based on cpu count vs # of shards (if 3.2+)
71-
self.threads_per_dump = 0
70+
# decide how many parallel dump workers to use based on cpu count vs # of shards (if 3.2+), 8 max workers max to protect the db
71+
self.threads_per_dump = 0
72+
self.threads_per_dump_max = 8
7273
if tuple(self.version.split(".")) >= tuple("3.2.0".split(".")):
7374
self.threads_per_dump = 1
7475
if self.cpu_count > len(self.secondaries):
7576
self.threads_per_dump = int(floor(self.cpu_count / len(self.secondaries)))
77+
if self.threads_per_dump > self.threads_per_dump_max:
78+
self.threads_per_dump = self.threads_per_dump_max
7679
else:
7780
logging.warn("Threading unsupported by mongodump version %s. Use mongodump 3.2.0 or greater to enable per-dump threading." % self.version)
7881

0 commit comments

Comments
 (0)