Skip to content

Commit 7e755b9

Browse files
dschnellertimvaillancourt
authored andcommitted
Add "--backup.mongodump.force_table_scan" option (#302)
If set, this enables mongodump's `--forceTableScan` option which can speed up dumps significantly, especially when custom id fields are used or when the id values are large. According to the discussion in [TOOLS-845](https://jira.mongodb.org/browse/TOOLS-845) this is safe to do for WiredTiger. * https://jira.mongodb.org/browse/TOOLS-845?focusedCommentId=988298&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-988298 * https://jira.mongodb.org/browse/TOOLS-845?focusedCommentId=988414&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-988414 Defaults to false.
1 parent 2f3b651 commit 7e755b9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def close(self, exit_code=None, frame=None):
6060
def do_ssl(self):
6161
return parse_config_bool(self.config.ssl.enabled)
6262

63+
def force_table_scan(self):
64+
return parse_config_bool(self.config.backup.mongodump.force_table_scan)
65+
6366
def do_ssl_insecure(self):
6467
return parse_config_bool(self.config.ssl.insecure)
6568

@@ -209,6 +212,10 @@ def mongodump_cmd(self):
209212
logging.fatal("Mongodump must be >= 2.6.0 to enable SSL encryption!")
210213
sys.exit(1)
211214

215+
if self.force_table_scan():
216+
logging.info("Enabling mongodump --forceTableScan option")
217+
mongodump_flags.append("--forceTableScan")
218+
212219
mongodump_cmd.extend(mongodump_flags)
213220
return mongodump_cmd
214221

mongodb_consistent_backup/Backup/Mongodump/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ def config(parser):
1010
parser.add_argument("--backup.mongodump.threads", dest="backup.mongodump.threads",
1111
help="Number of threads to use for each mongodump process. There is 1 x mongodump per shard, be careful! (default: shards/CPUs)",
1212
default=0, type=int)
13+
# for a detailled explanation see
14+
# see https://jira.mongodb.org/browse/TOOLS-845?focusedCommentId=988298&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-988298
15+
# and https://jira.mongodb.org/browse/TOOLS-845?focusedCommentId=988414&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-988414
16+
parser.add_argument("--backup.mongodump.force_table_scan", dest="backup.mongodump.force_table_scan", default=False,
17+
action="store_true", help="Enables mongodump's forceTableScan option. Useful if custom ids are "
18+
"used or id values are large. ONLY use with WiredTiger! (default: false)")
19+
1320
return parser

0 commit comments

Comments
 (0)