summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2021-10-11 17:24:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-12 14:04:56 +0000
commitd86b950b0504847dab1d5d22583c01e6a80c4593 (patch)
tree0c12dae6c0b199975341803ffa5141e3757f2c92
parent6427bb01da49015bbac8e6774aea4e90993053ae (diff)
downloadmongo-d86b950b0504847dab1d5d22583c01e6a80c4593.tar.gz
SERVER-60582: initiate_emrc_false.js should wait for the initial checkpoint before shutting down the secondary
(cherry picked from commit a3f74d55f2cd7731172ff509f8e6d6e59d67bc3b)
-rw-r--r--jstests/replsets/initiate_emrc_false.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/jstests/replsets/initiate_emrc_false.js b/jstests/replsets/initiate_emrc_false.js
index 6843c805405..f9fc7ca3880 100644
--- a/jstests/replsets/initiate_emrc_false.js
+++ b/jstests/replsets/initiate_emrc_false.js
@@ -6,6 +6,8 @@
(function() {
"use strict";
+load("jstests/core/txns/libs/prepare_helpers.js"); // getOldestRequiredTimestampForCrashRecovery()
+
function runTest({cleanShutdown}) {
const rst = new ReplSetTest({
name: jsTestName(),
@@ -35,7 +37,18 @@ function runTest({cleanShutdown}) {
}));
rst.awaitSecondaryNodes();
- let secondary = rst.getSecondary();
+ const secondary = rst.getSecondary();
+
+ // Wait until the secondary has an initial checkpoint.
+ assert.soon(() => {
+ const oldestRequiredTimestampForCrashRecovery =
+ PrepareHelpers.getOldestRequiredTimestampForCrashRecovery(secondary.getDB("admin"));
+ jsTestLog("Secondary oldestRequiredTimestampForCrashRecovery: " +
+ tojson(oldestRequiredTimestampForCrashRecovery));
+ return oldestRequiredTimestampForCrashRecovery &&
+ timestampCmp(oldestRequiredTimestampForCrashRecovery, Timestamp(0, 0)) > 0;
+ }, "Timeout waiting for the initial checkpoint", ReplSetTest.kDefaultTimeoutMS, 1000);
+
if (cleanShutdown) {
jsTestLog("Restarting secondary node from clean shutdown");
rst.stop(secondary, 0, undefined, {forRestart: true});
@@ -46,14 +59,14 @@ function runTest({cleanShutdown}) {
// Restarting from shutdown shouldn't need to go through initial sync again. Set a failpoint to
// hang initial sync so that if the node decides to do initial sync again, the test will fail.
- secondary = rst.start(secondary,
- {
- setParameter: {
- 'failpoint.initialSyncHangAfterGettingBeginFetchingTimestamp':
- tojson({mode: 'alwaysOn'}),
- }
- },
- true /* restart */);
+ rst.start(secondary,
+ {
+ setParameter: {
+ 'failpoint.initialSyncHangAfterGettingBeginFetchingTimestamp':
+ tojson({mode: 'alwaysOn'}),
+ }
+ },
+ true /* restart */);
rst.awaitSecondaryNodes();