summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2020-06-30 16:34:37 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-20 20:27:04 +0000
commit0b915dcc82121fbe11c605fa3f17fd52f796c070 (patch)
tree38292adc73a6a8bf03394f095e98b724b451b8c8 /src
parentf93fc644d454c9a949fd31c140d4ba93a2e819ce (diff)
downloadmongo-0b915dcc82121fbe11c605fa3f17fd52f796c070.tar.gz
SERVER-47884 Add 'disableLockFreeReads' startup server parameter and test suite.
The default for development is currently true, except in the test suite that sets it to false. Standalone mode and --enableReadConcernMajority=false cause an override to true.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/mongod_options.cpp30
-rw-r--r--src/mongo/db/storage/storage_options.h5
-rw-r--r--src/mongo/db/storage/storage_parameters.idl5
3 files changed, 40 insertions, 0 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index 0957953cf05..f0722782157 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -499,11 +499,41 @@ Status storeMongodOptions(const moe::Environment& params) {
// storage engines will continue to perform regular capped collection handling for the oplog
// collection, regardless of this parameter setting.
storageGlobalParams.allowOplogTruncation = false;
+
+ // Standalone mode does not currently support lock-free reads, so we disable it. If the user
+ // tries to explicitly enable it by specifying --disableLockFreeReads=false, log a warning
+ // so that the user knows the feature will not run in standalone mode.
+ if (!storageGlobalParams.disableLockFreeReads) {
+ LOGV2_WARNING(
+ 4788400,
+ "Lock-free reads is not supported in standalone mode: disabling lock-free reads.");
+ storageGlobalParams.disableLockFreeReads = true;
+ }
}
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;
+ }
+ }
+ }
+
+ // TODO (SERVER-49464): remove this development only extra logging.
+ if (storageGlobalParams.disableLockFreeReads) {
+ LOGV2(4788402, "Lock-free reads is disabled.");
+ } else {
+ LOGV2(4788403, "Lock-free reads is enabled.");
}
if (params.count("replication.oplogSizeMB")) {
diff --git a/src/mongo/db/storage/storage_options.h b/src/mongo/db/storage/storage_options.h
index 2d7e1a21ba7..4ede812a4d2 100644
--- a/src/mongo/db/storage/storage_options.h
+++ b/src/mongo/db/storage/storage_options.h
@@ -118,6 +118,11 @@ struct StorageGlobalParams {
// Controls whether we allow the OplogStones mechanism to delete oplog history on WT.
bool allowOplogTruncation = true;
+
+ // Disables lock-free reads, adjustable via setParameter. Can be disabled by certain user
+ // settings with which lock-free reads are incompatible: standalone mode; and
+ // enableMajorityReadConcern=false.
+ bool disableLockFreeReads;
};
extern StorageGlobalParams storageGlobalParams;
diff --git a/src/mongo/db/storage/storage_parameters.idl b/src/mongo/db/storage/storage_parameters.idl
index b2b78a52a0c..85e12b670f4 100644
--- a/src/mongo/db/storage/storage_parameters.idl
+++ b/src/mongo/db/storage/storage_parameters.idl
@@ -78,4 +78,9 @@ server_parameters:
default: 2048
validator:
gte: 1
+ disableLockFreeReads:
+ description: "Disables the lock-free reads feature."
+ set_at: [ startup ]
+ cpp_varname: 'storageGlobalParams.disableLockFreeReads'
+ default: true