summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-11-13 10:20:45 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-07 19:09:59 +0000
commit9c2c85fd6508e42ba3c277935e79b16cbe0237a5 (patch)
treefffd6fd4d396067d37cb7d22f2bf823e786f5932
parent07430d1cb41b102670783afeb21361d61b564783 (diff)
downloadmongo-9c2c85fd6508e42ba3c277935e79b16cbe0237a5.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.js4
-rw-r--r--jstests/replsets/libs/rollback_test_deluxe.js4
-rw-r--r--jstests/replsets/rollback_after_enabling_majority_reads.js8
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;