diff options
author | Pavi Vetriselvan <pavithra.vetriselvan@mongodb.com> | 2020-11-13 10:20:45 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-07 19:40:38 +0000 |
commit | a5fdda63afb540beca3743051666856fc05e3fbf (patch) | |
tree | 3e1aec7c60f7c79682b486cd535be57af17e4bae | |
parent | 936fbbe8b45ed9a9a5ba78a327d3f0f6cb3974d2 (diff) | |
download | mongo-a5fdda63afb540beca3743051666856fc05e3fbf.tar.gz |
SERVER-52744 rollback_after_enabling_majority_reads.js should ensure sync source's lastApplied > rollback node's
(cherry picked from commit 6623c6adf0445f1f63afe7a51433a1f5cbf4b4e1)
-rw-r--r-- | jstests/replsets/libs/rollback_test.js | 4 | ||||
-rw-r--r-- | jstests/replsets/libs/rollback_test_deluxe.js | 4 | ||||
-rw-r--r-- | jstests/replsets/rollback_after_enabling_majority_reads.js | 7 |
3 files changed, 11 insertions, 4 deletions
diff --git a/jstests/replsets/libs/rollback_test.js b/jstests/replsets/libs/rollback_test.js index 4e307651917..5faf7eed6bc 100644 --- a/jstests/replsets/libs/rollback_test.js +++ b/jstests/replsets/libs/rollback_test.js @@ -328,7 +328,7 @@ function RollbackTest(name = "RollbackTest", replSet) { * Insert on primary until its lastApplied >= the rollback node's. Useful for testing rollback * via refetch, which completes rollback recovery when new lastApplied >= old top of oplog. */ - const _awaitPrimaryAppliedSurpassesRollbackApplied = function() { + this.awaitPrimaryAppliedSurpassesRollbackApplied = function() { log(`Waiting for lastApplied on sync source ${curPrimary.host} to surpass lastApplied` + ` on rollback node ${curSecondary.host}`); @@ -417,7 +417,7 @@ function RollbackTest(name = "RollbackTest", replSet) { assert.commandWorked(curSecondary.adminCommand({serverStatus: 1})) .storageEngine.supportsCommittedReads; if (!isMajorityReadConcernEnabledOnRollbackNode) { - _awaitPrimaryAppliedSurpassesRollbackApplied(); + this.awaitPrimaryAppliedSurpassesRollbackApplied(); } return curPrimary; diff --git a/jstests/replsets/libs/rollback_test_deluxe.js b/jstests/replsets/libs/rollback_test_deluxe.js index 224b74f2254..a989dc1fb96 100644 --- a/jstests/replsets/libs/rollback_test_deluxe.js +++ b/jstests/replsets/libs/rollback_test_deluxe.js @@ -462,7 +462,7 @@ function RollbackTestDeluxe(name = "FiveNodeDoubleRollbackTest", replSet) { * Insert on primary until its lastApplied >= the rollback node's. Useful for testing rollback * via refetch, which completes rollback recovery when new lastApplied >= old top of oplog. */ - const _awaitPrimaryAppliedSurpassesRollbackApplied = function() { + this.awaitPrimaryAppliedSurpassesRollbackApplied = function() { log(`Waiting for lastApplied on sync source ${curPrimary.host} to surpass lastApplied` + ` on rollback node ${rollbackSecondary.host}`); @@ -545,7 +545,7 @@ function RollbackTestDeluxe(name = "FiveNodeDoubleRollbackTest", replSet) { assert.commandWorked(standbySecondary.adminCommand("replSetGetRBID")).rbid; if (jsTest.options().enableMajorityReadConcern === false) { - _awaitPrimaryAppliedSurpassesRollbackApplied(); + this.awaitPrimaryAppliedSurpassesRollbackApplied(); } return curPrimary; diff --git a/jstests/replsets/rollback_after_enabling_majority_reads.js b/jstests/replsets/rollback_after_enabling_majority_reads.js index 2b28be52e2a..96dc86e89ec 100644 --- a/jstests/replsets/rollback_after_enabling_majority_reads.js +++ b/jstests/replsets/rollback_after_enabling_majority_reads.js @@ -39,6 +39,13 @@ // Make sure the primary has not changed. assert.neq(rollbackTest.getPrimary(), rollbackNode); + // The first rollback attempt with EMRC=true will fassert, so we expect the actual rollback to + // occur with EMRC=false. Before the second rollback (via refetch) occurs, we must ensure that + // the sync source's lastApplied is greater than the rollback node's. Otherwise, the rollback + // node will never transition to SECONDARY since the rollback node's lastApplied will be less + // than the initialDataTS. See SERVER-48518 for a more detailed explanation of this behavior. + rollbackTest.awaitPrimaryAppliedSurpassesRollbackApplied(); + // The rollback crashes because we have not yet set a stable timestamp. jsTest.log("Attempt to roll back. This will fassert."); rollbackTest.transitionToSyncSourceOperationsDuringRollback(); |