summaryrefslogtreecommitdiff
path: root/mongodump
diff options
context:
space:
mode:
authorKyle Erf <erf@mongodb.com>2015-06-09 13:16:30 -0400
committerKyle Erf <erf@mongodb.com>2015-06-17 18:05:24 -0400
commiteddd6c57f1f372accb85c93d471a58957e2918b6 (patch)
treeea6bdf4d55fd3a2c8fa0504ab6ed18103e8de4fc /mongodump
parentd9eb416979dabf2717bdac2de970eff38a2d557a (diff)
downloadmongo-eddd6c57f1f372accb85c93d471a58957e2918b6.tar.gz
TOOLS-16 mongodump: disable secondary reads when connected to a mongos
Diffstat (limited to 'mongodump')
-rw-r--r--mongodump/mongodump.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/mongodump/mongodump.go b/mongodump/mongodump.go
index 816063f0b26..1e548022405 100644
--- a/mongodump/mongodump.go
+++ b/mongodump/mongodump.go
@@ -94,16 +94,28 @@ func (dump *MongoDump) Init() error {
if err != nil {
return fmt.Errorf("can't create session: %v", err)
}
- // ensure we allow secondary reads and disable TCP timeouts
- dump.sessionProvider.SetFlags(db.Monotonic | db.DisableSocketTimeout)
+
+ // allow secondary reads for the isMongos check
+ dump.sessionProvider.SetFlags(db.Monotonic)
dump.isMongos, err = dump.sessionProvider.IsMongos()
if err != nil {
return err
}
- // return a helpful error message for mongos
+
+ // ensure we allow secondary reads on mongods and disable TCP timeouts
+ flags := db.DisableSocketTimeout
+ if dump.isMongos {
+ log.Logf(log.Info, "connecting to mongos; secondary reads disabled")
+ } else {
+ flags |= db.Monotonic
+ }
+ dump.sessionProvider.SetFlags(flags)
+
+ // return a helpful error message for mongos --repair
if dump.OutputOptions.Repair && dump.isMongos {
return fmt.Errorf("--repair flag cannot be used on a mongos")
}
+
dump.manager = intents.NewIntentManager()
dump.progressManager = progress.NewProgressBarManager(log.Writer(0), progressBarWaitTime)
return nil