summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXueruiFa <xuerui.fa@mongodb.com>2021-10-14 13:54:49 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-14 14:25:44 +0000
commit545f68ac4ceb4c7f88dec633a1a6eb96c922c9fd (patch)
tree52b48f3df9f5b9f008994849d087dadaa33b5df5
parent556a8f646b06609857e96c9735e4669c2598af7f (diff)
downloadmongo-545f68ac4ceb4c7f88dec633a1a6eb96c922c9fd.tar.gz
SERVER-60096: Add rollbackHangCommonPointBeforeReplCommitPoint failpoint to RVR
-rw-r--r--jstests/replsets/resync_majority_member.js13
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp9
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp9
3 files changed, 24 insertions, 7 deletions
diff --git a/jstests/replsets/resync_majority_member.js b/jstests/replsets/resync_majority_member.js
index e2b4a50bb63..221e4e2b2fc 100644
--- a/jstests/replsets/resync_majority_member.js
+++ b/jstests/replsets/resync_majority_member.js
@@ -11,8 +11,9 @@
(function() {
"use strict";
-load("jstests/libs/write_concern_util.js");
load("jstests/libs/fail_point_util.js");
+load("jstests/libs/storage_engine_utils.js");
+load("jstests/libs/write_concern_util.js");
TestData.skipCheckDBHashes = true; // the set is not consistent when we shutdown the test
@@ -90,8 +91,14 @@ assert.commandWorked(syncSource.getDB(dbName).getCollection(collName).insert(
// This failpoint will only be hit if the node's rollback common point is before the replication
// commit point, which triggers an invariant. This failpoint is used to verify the invariant
// will be hit without having to search the logs.
-const rollbackCommittedWritesFailPoint =
- configureFailPoint(rollbackNode, "rollbackHangCommonPointBeforeReplCommitPoint");
+let rollbackCommittedWritesFailPoint;
+if (storageEngineIsWiredTigerOrInMemory() && jsTest.options().enableMajorityReadConcern !== false) {
+ rollbackCommittedWritesFailPoint =
+ configureFailPoint(rollbackNode, "rollbackToTimestampHangCommonPointBeforeReplCommitPoint");
+} else {
+ rollbackCommittedWritesFailPoint =
+ configureFailPoint(rollbackNode, "rollbackViaRefetchHangCommonPointBeforeReplCommitPoint");
+}
// Node 1 will have to roll back to rejoin the set. It will crash as it will refuse to roll back
// majority committed data.
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index 1192be4979f..707ce65dd41 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -72,7 +72,7 @@ namespace repl {
using namespace fmt::literals;
MONGO_FAIL_POINT_DEFINE(rollbackHangAfterTransitionToRollback);
-MONGO_FAIL_POINT_DEFINE(rollbackHangCommonPointBeforeReplCommitPoint);
+MONGO_FAIL_POINT_DEFINE(rollbackToTimestampHangCommonPointBeforeReplCommitPoint);
namespace {
@@ -1014,10 +1014,11 @@ StatusWith<RollBackLocalOperations::RollbackCommonPoint> RollbackImpl::_findComm
"commonPointOpTime"_attr = commonPointOpTime);
// This failpoint is used for testing the invariant below.
- if (MONGO_unlikely(rollbackHangCommonPointBeforeReplCommitPoint.shouldFail()) &&
+ if (MONGO_unlikely(rollbackToTimestampHangCommonPointBeforeReplCommitPoint.shouldFail()) &&
(commonPointOpTime.getTimestamp() < lastCommittedOpTime.getTimestamp())) {
- LOGV2(5812200, "Hanging due to rollbackHangCommonPointBeforeReplCommitPoint failpoint");
- rollbackHangCommonPointBeforeReplCommitPoint.pauseWhileSet(opCtx);
+ LOGV2(5812200,
+ "Hanging due to rollbackToTimestampHangCommonPointBeforeReplCommitPoint failpoint");
+ rollbackToTimestampHangCommonPointBeforeReplCommitPoint.pauseWhileSet(opCtx);
}
// Rollback common point should be >= the replication commit point.
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 8b8a4d37eca..2bd919e53c6 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -97,6 +97,7 @@ using std::unique_ptr;
namespace repl {
MONGO_FAIL_POINT_DEFINE(rollbackExitEarlyAfterCollectionDrop);
+MONGO_FAIL_POINT_DEFINE(rollbackViaRefetchHangCommonPointBeforeReplCommitPoint);
using namespace rollback_internal;
@@ -1282,6 +1283,14 @@ Status _syncRollback(OperationContext* opCtx,
"Rollback common point",
"commonPoint"_attr = commonPointOpTime);
+ // This failpoint is used for testing the invariant below.
+ if (MONGO_unlikely(rollbackViaRefetchHangCommonPointBeforeReplCommitPoint.shouldFail()) &&
+ (commonPointOpTime.getTimestamp() < lastCommittedOpTime.getTimestamp())) {
+ LOGV2(6009600,
+ "Hanging due to rollbackViaRefetchHangCommonPointBeforeReplCommitPoint failpoint");
+ rollbackViaRefetchHangCommonPointBeforeReplCommitPoint.pauseWhileSet(opCtx);
+ }
+
// Rollback common point should be >= the replication commit point.
invariant(commonPointOpTime.getTimestamp() >= lastCommittedOpTime.getTimestamp());
invariant(commonPointOpTime >= lastCommittedOpTime);