Skip to content

Commit 99c1d6a

Browse files
committed
pass MaxProcs explicitly to mongodump/mongorestore
1 parent e1873a1 commit 99c1d6a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pbm/snapshot/backup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package snapshot
33
import (
44
"io"
55
"log"
6+
"runtime"
67
"time"
78

89
"github.com/mongodb/mongo-tools/common/archive"
@@ -45,6 +46,9 @@ func NewBackup(curi string, maxParallelColls int, d, c string) (*backuper, error
4546
}
4647
}
4748

49+
// mongodump calls runtime.GOMAXPROCS(MaxProcs).
50+
opts.MaxProcs = runtime.GOMAXPROCS(0)
51+
4852
if maxParallelColls < 1 {
4953
maxParallelColls = 1
5054
}

pbm/snapshot/restore.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package snapshot
22

33
import (
44
"io"
5+
"runtime"
56

67
"github.com/mongodb/mongo-tools/common/options"
78
"github.com/mongodb/mongo-tools/mongorestore"
@@ -99,6 +100,8 @@ func NewRestore(uri string, cfg *config.Config, numParallelColls int) (io.Reader
99100
mopts.NSOptions = &mongorestore.NSOptions{
100101
NSExclude: ExcludeFromRestore,
101102
}
103+
// mongorestore calls runtime.GOMAXPROCS(MaxProcs).
104+
mopts.MaxProcs = runtime.GOMAXPROCS(0)
102105

103106
mr, err := mongorestore.New(mopts)
104107
if err != nil {

0 commit comments

Comments
 (0)