summaryrefslogtreecommitdiff
path: root/src/mongo/db/mongod_options.cpp
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2021-01-11 10:45:19 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-19 18:48:35 +0000
commit7a1bb02d3a93f72592ceef13eb5b45e74ca1d83e (patch)
tree3c39138ce344375acd1ab7ad1b902b9f4deebaaf /src/mongo/db/mongod_options.cpp
parenta5070b29b39983eb13d3ae8f0b9f5d0212e828ce (diff)
downloadmongo-7a1bb02d3a93f72592ceef13eb5b45e74ca1d83e.tar.gz
SERVER-53247 disable enableMajorityReadConcern=false for non-test storage engines
Diffstat (limited to 'src/mongo/db/mongod_options.cpp')
-rw-r--r--src/mongo/db/mongod_options.cpp71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index c816d63a5a8..c4e32e132dc 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -143,6 +143,12 @@ bool handlePreValidationMongodOptions(const moe::Environment& params,
return false;
}
+ if (params.count("replication.enableMajorityReadConcern") &&
+ params["replication.enableMajorityReadConcern"].as<bool>() == false) {
+ LOGV2_FATAL_CONTINUE(5324700, "enableMajorityReadConcern:false is no longer supported");
+ return false;
+ }
+
return true;
}
@@ -346,8 +352,6 @@ Status canonicalizeMongodOptions(moe::Environment* params) {
return Status::OK();
}
-bool gIgnoreEnableMajorityReadConcernWarning = false;
-
Status storeMongodOptions(const moe::Environment& params) {
Status ret = storeServerOptions(params);
if (!ret.isOK()) {
@@ -524,21 +528,28 @@ Status storeMongodOptions(const moe::Environment& params) {
<< "security.keyFile is required when authorization is enabled with replica sets");
}
- if (params.count("replication.enableMajorityReadConcern")) {
- serverGlobalParams.enableMajorityReadConcern =
- params["replication.enableMajorityReadConcern"].as<bool>();
-
- if (!serverGlobalParams.enableMajorityReadConcern) {
- // Lock-free reads are not supported with enableMajorityReadConcern=false, so we disable
- // them. If the user tries to explicitly enable lock-free reads by specifying
- // disableLockFreeReads=false, log a warning so that the user knows these are not
- // compatible settings.
- if (!storageGlobalParams.disableLockFreeReads) {
- LOGV2_WARNING(4788401,
- "Lock-free reads is not compatible with "
- "enableMajorityReadConcern=false: disabling lock-free reads.");
- storageGlobalParams.disableLockFreeReads = true;
- }
+ serverGlobalParams.enableMajorityReadConcern = true;
+
+ if (storageGlobalParams.engineSetByUser &&
+ (storageGlobalParams.engine == "ephemeralForTest" ||
+ storageGlobalParams.engine == "devnull")) {
+ LOGV2(5324701,
+ "Test storage engine does not support enableMajorityReadConcern=true, forcibly "
+ "setting to false",
+ "storageEngine"_attr = storageGlobalParams.engine);
+ serverGlobalParams.enableMajorityReadConcern = false;
+ }
+
+ if (!serverGlobalParams.enableMajorityReadConcern) {
+ // Lock-free reads are not supported with enableMajorityReadConcern=false, so we disable
+ // them. If the user tries to explicitly enable lock-free reads by specifying
+ // disableLockFreeReads=false, log a warning so that the user knows these are not
+ // compatible settings.
+ if (!storageGlobalParams.disableLockFreeReads) {
+ LOGV2_WARNING(4788401,
+ "Lock-free reads is not compatible with "
+ "enableMajorityReadConcern=false: disabling lock-free reads.");
+ storageGlobalParams.disableLockFreeReads = true;
}
}
@@ -601,12 +612,11 @@ Status storeMongodOptions(const moe::Environment& params) {
auto clusterRoleParam = params["sharding.clusterRole"].as<std::string>();
if (clusterRoleParam == "configsvr") {
serverGlobalParams.clusterRole = ClusterRole::ConfigServer;
-
- if (params.count("replication.enableMajorityReadConcern") &&
- !params["replication.enableMajorityReadConcern"].as<bool>()) {
- gIgnoreEnableMajorityReadConcernWarning = true;
- }
- serverGlobalParams.enableMajorityReadConcern = true;
+ // Config server requires majority read concern.
+ uassert(5324702,
+ str::stream() << "Cannot initialize config server with "
+ << "enableMajorityReadConcern=false",
+ serverGlobalParams.enableMajorityReadConcern);
// If we haven't explicitly specified a journal option, default journaling to true for
// the config server role
@@ -682,19 +692,4 @@ Status storeMongodOptions(const moe::Environment& params) {
return Status::OK();
}
-// This warning must be deferred until after ServerLogRedirection has started up so that it goes to
-// the right place. This initializer depends on the "default" initializer, which in turn depends on
-// the "ServerLogRedirection". This ensures that when this initializer is run, the log redirection
-// to file, if any, is ready. The reason for depending on "default" instead of
-// "ServerLogRedirection" is that this way we avoid having to add a dummy "ServerLogRedirection"
-// initializer in each one of the unit tests that depend on mongod_options.
-MONGO_INITIALIZER(IgnoreEnableMajorityReadConcernWarning)
-(InitializerContext*) {
- if (gIgnoreEnableMajorityReadConcernWarning) {
- LOGV2_WARNING(20879,
- "Ignoring read concern override as config server requires majority read "
- "concern");
- }
-}
-
} // namespace mongo