diff options
-rw-r--r-- | etc/evergreen.yml | 29 | ||||
-rw-r--r-- | jstests/noPassthrough/disable_lock_free_reads_server_parameter.js | 69 | ||||
-rw-r--r-- | src/mongo/db/mongod_options.cpp | 30 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_options.h | 5 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_parameters.idl | 5 |
5 files changed, 138 insertions, 0 deletions
diff --git a/etc/evergreen.yml b/etc/evergreen.yml index cd3071f61d0..023d54d3c88 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -10366,6 +10366,35 @@ buildvariants: - name: snmp - name: .updatefuzzer +- name: enterprise-rhel-62-64-bit-lock-free-reads + display_name: "Enterprise RHEL 6.2 (Lock Free Reads)" + modules: + - enterprise + run_on: + - rhel62-small + expansions: &enterprise-rhel-62-64-bit-lock-free-reads-expansions + test_flags: >- + --mongodSetParameters="{disableLockFreeReads: false}" + compile_flags: >- + -j$(grep -c ^processor /proc/cpuinfo) + --ssl + --variables-files=etc/scons/mongodbtoolchain_v3_gcc.vars + MONGO_DISTMOD=rhel62 + multiversion_platform: rhel62 + multiversion_edition: enterprise + repo_edition: enterprise + scons_cache_scope: shared + build_mongoreplay: false + large_distro_name: rhel62-large + # Additions of tasks already defining '--mongodSetParameters' will override this test suite's parameter settings (SERVER-47509). + tasks: + - name: compile_TG + distros: + - rhel62-large + # jsCore does not exercise the lock-free reads feature, as it is overridden to disabled on standalones, but is a pre-req for other tasks. + - name: jsCore + - name: .replica_sets + - name: enterprise-rhel-62-64-bit-coverage display_name: "~ Enterprise RHEL 6.2 DEBUG Code Coverage" modules: diff --git a/jstests/noPassthrough/disable_lock_free_reads_server_parameter.js b/jstests/noPassthrough/disable_lock_free_reads_server_parameter.js new file mode 100644 index 00000000000..05e9687324c --- /dev/null +++ b/jstests/noPassthrough/disable_lock_free_reads_server_parameter.js @@ -0,0 +1,69 @@ +/** + * Tests the 'disableLockFreeReads' startup setParameter. + * + * User set disableLockFreeReads will be overridden to true (disabled) if: + * - in standalone mode + * - with enableMajorityReadConcern=false + * Otherwise, the default for disableLockFreeReads is true. + * + * @tags: [ + * # This test expects enableMajorityReadConcern to be on by default and cannot run in suites + * # that explicitly change that. + * requires_majority_read_concern, + * requires_replication, + * ] + */ + +(function() { +"use strict"; + +const replSetName = 'disable_lock_free_reads_server_parameter'; + +jsTest.log("Starting server with disableLockFreeReads=false in standalone mode: this should " + + "override the setting to true."); + +let conn = MongoRunner.runMongod({setParameter: "disableLockFreeReads=false"}); +assert.neq(conn, null); +checkLog.contains(conn, "disabling lock-free reads"); +checkLog.contains(conn, "Lock-free reads is disabled"); +MongoRunner.stopMongod(conn); + +jsTest.log("Starting server with disableLockFreeReads=false and enableMajorityReadConcern=false: " + + "this should override the setting to true."); + +conn = MongoRunner.runMongod({ + replSet: replSetName, + enableMajorityReadConcern: false, + setParameter: "disableLockFreeReads=false" +}); +assert.neq(conn, null); +checkLog.contains(conn, "disabling lock-free reads"); +checkLog.contains(conn, "Lock-free reads is disabled"); +MongoRunner.stopMongod(conn); + +jsTest.log("Starting server in standalone mode with disableLockFreeReads=true: this is the " + + "default and nothing should happen."); + +conn = MongoRunner.runMongod({setParameter: "disableLockFreeReads=true"}); +assert.neq(conn, null); +assert(!checkLog.checkContainsOnce(conn, "disabling lock-free reads")); +checkLog.contains(conn, "Lock-free reads is disabled"); +MongoRunner.stopMongod(conn); + +jsTest.log("Starting server as a replica set member with disableLockFreeReads=false: this should " + + "turn on lock-free reads."); + +conn = MongoRunner.runMongod({replSet: replSetName, setParameter: "disableLockFreeReads=false"}); +assert.neq(conn, null); +checkLog.contains(conn, "Lock-free reads is enabled"); +MongoRunner.stopMongod(conn); + +jsTest.log("Starting server as a replica set member with disableLockFreeReads=true: this is the " + + "default and nothing should happen."); + +conn = MongoRunner.runMongod({replSet: replSetName, setParameter: "disableLockFreeReads=true"}); +assert.neq(conn, null); +assert(!checkLog.checkContainsOnce(conn, "disabling lock-free reads")); +checkLog.contains(conn, "Lock-free reads is disabled"); +MongoRunner.stopMongod(conn); +}()); 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 |