diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-12-12 16:05:09 -0500 |
---|---|---|
committer | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2019-01-14 11:41:02 -0500 |
commit | 26034f8f214194484c6eefe0360740f52febdda6 (patch) | |
tree | a0f2b27b368104ce5307377617a7811ed519aba8 | |
parent | 8fa57b8981903e54d6bee624abd10aa1311493c0 (diff) | |
download | mongo-26034f8f214194484c6eefe0360740f52febdda6.tar.gz |
SERVER-37240 Enable dbhash background thread for enableMajorityReadConcern:false variant
(cherry picked from commit 0991709cf60677b183cc0362e432c095d9ed185f)
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/dbhash_background.py | 5 | ||||
-rw-r--r-- | jstests/hooks/run_check_repl_dbhash_background.js | 35 |
2 files changed, 27 insertions, 13 deletions
diff --git a/buildscripts/resmokelib/testing/hooks/dbhash_background.py b/buildscripts/resmokelib/testing/hooks/dbhash_background.py index 7d4790fe1fd..b8122f458b8 100644 --- a/buildscripts/resmokelib/testing/hooks/dbhash_background.py +++ b/buildscripts/resmokelib/testing/hooks/dbhash_background.py @@ -36,11 +36,6 @@ class CheckReplDBHashInBackground(jsfile.JSHook): " doesn't support snapshot reads.", server_status["storageEngine"]["name"]) return - if not server_status["storageEngine"].get("supportsCommittedReads", False): - self.logger.info("Not enabling the background thread because '%s' storage engine" - " doesn't support committed reads.", - server_status["storageEngine"]["name"]) - return if not server_status["storageEngine"].get("persistent", False): self.logger.info("Not enabling the background thread because '%s' storage engine" " is not persistent.", server_status["storageEngine"]["name"]) diff --git a/jstests/hooks/run_check_repl_dbhash_background.js b/jstests/hooks/run_check_repl_dbhash_background.js index 83079541e8d..d3029ea27ba 100644 --- a/jstests/hooks/run_check_repl_dbhash_background.js +++ b/jstests/hooks/run_check_repl_dbhash_background.js @@ -136,14 +136,33 @@ // doesn't exceed the node's notion of the latest clusterTime. session.advanceClusterTime(sessions[0].getClusterTime()); - // We do an afterClusterTime read on a nonexistent collection to wait for the secondary - // to have applied up to 'clusterTime' and advanced its majority commit point. - assert.commandWorked(db.runCommand({ - find: 'run_check_repl_dbhash_background', - readConcern: {level: 'majority', afterClusterTime: clusterTime}, - limit: 1, - singleBatch: true, - })); + // We need to make sure the secondary has applied up to 'clusterTime' and advanced its + // majority commit point. + + if (jsTest.options().enableMajorityReadConcern !== false) { + // If majority reads are supported, we can issue an afterClusterTime read on + // a nonexistent collection and wait on it. This has the advantage of being easier + // to debug in case of a timeout. + assert.commandWorked(db.runCommand({ + find: 'run_check_repl_dbhash_background', + readConcern: {level: 'majority', afterClusterTime: clusterTime}, + limit: 1, + singleBatch: true, + })); + } else { + // If majority reads are not supported, then our only option is to poll for the + // lastOpCommitted on the secondary to catch up. + assert.soon( + function() { + const rsStatus = + assert.commandWorked(db.adminCommand({replSetGetStatus: 1})); + const committedOpTime = rsStatus.optimes.lastCommittedOpTime; + return bsonWoCompare(committedOpTime.ts, clusterTime) >= 0; + }, + "The majority commit point on secondary " + i + " failed to reach " + + clusterTime, + 10 * 60 * 1000); + } } }; |