Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default mongo storage backend to mmapv1 #126

Merged
merged 1 commit into from
May 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions mgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,31 @@ var (
// regular expression to match output of mongod
waitingForConnectionsRe = regexp.MustCompile(".*waiting for connections.*")

mongo32 = version.Number{Major: 3, Minor: 2}

// After version 3.2 we shouldn't use --nojournal - it makes the
// WiredTiger storage engine much slower.
// https://jira.mongodb.org/browse/SERVER-21198
useJournalMongoVersion = version.Number{Major: 3, Minor: 2}
installedMongod mongodCache
useJournalMongoVersion = mongo32

// From mongo 3.2 onwards, we can specify a storage engine.
storageEngineMongoVersion = mongo32

installedMongod mongodCache
)

const (
// Maximum number of times to attempt starting mongod.
maxStartMongodAttempts = 5

// The default password to use when connecting to the mongo database.
DefaultMongoPassword = "conn-from-name-secret"

// defaultMongoStorageEngine is the default storage engine to use
// in Mongo 3.2 onwards for tests. We default to mmapv1 (vs. the
// mongo default of wiredTiger) for the best performance in tests,
// but make it configurable.
defaultMongoStorageEngine = "mmapv1"
)

// Certs holds the certificates and keys required to make a secure
Expand Down Expand Up @@ -248,6 +261,13 @@ func (inst *MgoInstance) run() error {
if version.Compare(useJournalMongoVersion) == -1 {
mgoargs = append(mgoargs, "--nojournal")
}
if version.Compare(storageEngineMongoVersion) >= 0 {
storageEngine := os.Getenv("JUJU_MONGO_STORAGE_ENGINE")
if storageEngine == "" {
storageEngine = defaultMongoStorageEngine
}
mgoargs = append(mgoargs, "--storageEngine", storageEngine)
}

if inst.Params != nil {
mgoargs = append(mgoargs, inst.Params...)
Expand Down