diff options
-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 | 8 |
3 files changed, 12 insertions, 4 deletions
diff --git a/jstests/replsets/libs/rollback_test.js b/jstests/replsets/libs/rollback_test.js index ffab6f0b5cb..a2c9980909e 100644 --- a/jstests/replsets/libs/rollback_test.js +++ b/jstests/replsets/libs/rollback_test.js @@ -349,7 +349,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}`); @@ -441,7 +441,7 @@ function RollbackTest(name = "RollbackTest", replSet) { assert.commandWorked(curSecondary.adminCommand({serverStatus: 1})) .storageEngine.supportsCommittedReads; if (!isMajorityReadConcernEnabledOnRollbackNode) { - _awaitPrimaryAppliedSurpassesRollbackApplied(); + this.awaitPrimaryAppliedSurpassesRollbackApplied(); } // The current primary, which is the old secondary, will later become the sync source. diff --git a/jstests/replsets/libs/rollback_test_deluxe.js b/jstests/replsets/libs/rollback_test_deluxe.js index 9e254b9a041..3e9b9ec4a82 100644 --- a/jstests/replsets/libs/rollback_test_deluxe.js +++ b/jstests/replsets/libs/rollback_test_deluxe.js @@ -461,7 +461,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}`); @@ -544,7 +544,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 bbf963e2deb..a7d0b76497d 100644 --- a/jstests/replsets/rollback_after_enabling_majority_reads.js +++ b/jstests/replsets/rollback_after_enabling_majority_reads.js @@ -49,6 +49,14 @@ assert.eq(replSetGetStatusResponse.lastStableCheckpointTimestamp, // The rollback crashes because the common point is before the stable timestamp. jsTest.log("Attempt to roll back. This will fassert."); rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); + +// 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(); + rollbackTest.transitionToSyncSourceOperationsDuringRollback(); assert.soon(() => { return rawMongoProgramOutput().indexOf("Fatal Assertion 51121") !== -1; |