diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2019-03-15 16:15:03 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2019-03-19 11:43:25 -0400 |
commit | def336dd7510b42c7fbdea22030d0ef5c39bd541 (patch) | |
tree | f2d2897d015c088c257da6ee81e7785d56061bb9 /src/mongo/db/mongod_options.cpp | |
parent | 6fa88f8fe4fec7c1bdef30ddf1ef46163eab5a79 (diff) | |
download | mongo-def336dd7510b42c7fbdea22030d0ef5c39bd541.tar.gz |
SERVER-36772 Ensure oplog history cannot be truncated in standalone mode with the WT storage engine.
Adds an 'allowOplogTruncation' storageGlobalParam, which is set to false for standalones.
Diffstat (limited to 'src/mongo/db/mongod_options.cpp')
-rw-r--r-- | src/mongo/db/mongod_options.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 2312596120a..3c5deb111be 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -470,12 +470,29 @@ Status storeMongodOptions(const moe::Environment& params) { } repl::ReplSettings replSettings; - if (params.count("replication.replSetName")) { - replSettings.setReplSetString(params["replication.replSetName"].as<std::string>().c_str()); - } if (params.count("replication.replSet")) { /* seed list of hosts for the repl set */ replSettings.setReplSetString(params["replication.replSet"].as<std::string>().c_str()); + } else if (params.count("replication.replSetName")) { + // "replSetName" is previously removed if "replSet" and "replSetName" are both found to be + // set by the user. Therefore, we only need to check for it if "replSet" in not found. + replSettings.setReplSetString(params["replication.replSetName"].as<std::string>().c_str()); + } else { + // If neither "replication.replSet" nor "replication.replSetName" is set, then we are in + // standalone mode. + // + // A standalone node does not use the oplog collection, so special truncation handling for + // the capped collection is unnecessary. + // + // A standalone node that will be reintroduced to its replica set must not allow oplog + // truncation while in standalone mode because oplog history needed for startup recovery as + // a replica set member could be deleted. Replication can need history older than the last + // checkpoint to support transactions. + // + // Note: we only use this to defer oplog collection truncation via OplogStones in WT. Non-WT + // storage engines will continue to perform regular capped collection handling for the oplog + // collection, regardless of this parameter setting. + storageGlobalParams.allowOplogTruncation = false; } if (params.count("replication.enableMajorityReadConcern")) { |