diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-12-12 16:05:09 -0500 |
---|---|---|
committer | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-12-14 14:35:19 -0500 |
commit | 0991709cf60677b183cc0362e432c095d9ed185f (patch) | |
tree | de5c67991dd847245c6e65d45cfab186c70ff25c /jstests/hooks | |
parent | a8a31599ee42125071e9c1b5033d114444a2e40f (diff) | |
download | mongo-0991709cf60677b183cc0362e432c095d9ed185f.tar.gz |
SERVER-37240 Enable dbhash background thread for enableMajorityReadConcern:false variant
Diffstat (limited to 'jstests/hooks')
-rw-r--r-- | jstests/hooks/run_check_repl_dbhash_background.js | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/jstests/hooks/run_check_repl_dbhash_background.js b/jstests/hooks/run_check_repl_dbhash_background.js index d15c8f52c42..864f13a0945 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); + } } }; |