diff options
author | William Schultz <william.schultz@mongodb.com> | 2020-06-11 22:55:28 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-12 03:09:39 +0000 |
commit | 15d91aaf3793f1a93b6b1774d8eb55af7888cce8 (patch) | |
tree | f63b38a57ad30303f43ce497e582bab3bbd5d0ea /src | |
parent | cc80078a7c3c2469ee6de39791cf0288e6771ef1 (diff) | |
download | mongo-15d91aaf3793f1a93b6b1774d8eb55af7888cce8.tar.gz |
SERVER-48707 Move replication recovery invariant behind test only flag
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/repl_server_parameters.idl | 8 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_recovery.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_recovery_test.cpp | 8 | ||||
-rw-r--r-- | src/mongo/shell/servers.js | 8 |
5 files changed, 34 insertions, 5 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index f4a43da5dd7..c0d4a3cbc31 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -269,6 +269,7 @@ env.Library( LIBDEPS_PRIVATE=[ 'oplog', 'oplog_application', + 'repl_server_parameters', '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/storage/storage_options', ], diff --git a/src/mongo/db/repl/repl_server_parameters.idl b/src/mongo/db/repl/repl_server_parameters.idl index ba55667b7b9..6033dc3a5f9 100644 --- a/src/mongo/db/repl/repl_server_parameters.idl +++ b/src/mongo/db/repl/repl_server_parameters.idl @@ -288,3 +288,11 @@ server_parameters: # and if it is not, readPreference is 'nearest'. default: "" validator: { callback: 'validateReadPreferenceMode' } + + assertStableTimestampEqualsAppliedThroughOnRecovery: + description: Enables invariant to check stable timestamp equals appliedThrough on recovery. + set_at: startup + test_only: true + cpp_vartype: bool + cpp_varname: assertStableTimestampEqualsAppliedThroughOnRecovery + default: false
\ No newline at end of file diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp index 9259013bcc8..2d363d6a579 100644 --- a/src/mongo/db/repl/replication_recovery.cpp +++ b/src/mongo/db/repl/replication_recovery.cpp @@ -43,6 +43,7 @@ #include "mongo/db/repl/apply_ops.h" #include "mongo/db/repl/oplog_applier_impl.h" #include "mongo/db/repl/oplog_buffer.h" +#include "mongo/db/repl/repl_server_parameters_gen.h" #include "mongo/db/repl/replication_consistency_markers_impl.h" #include "mongo/db/repl/storage_interface.h" #include "mongo/db/repl/transaction_oplog_application.h" @@ -427,11 +428,14 @@ void ReplicationRecoveryImpl::recoverFromOplog(OperationContext* opCtx, } const auto appliedThrough = _consistencyMarkers->getAppliedThrough(opCtx); - invariant(!stableTimestamp || stableTimestamp->isNull() || appliedThrough.isNull() || - *stableTimestamp == appliedThrough.getTimestamp(), - str::stream() << "Stable timestamp " << stableTimestamp->toString() - << " does not equal appliedThrough timestamp " - << appliedThrough.toString()); + if (assertStableTimestampEqualsAppliedThroughOnRecovery) { + invariant(!stableTimestamp || stableTimestamp->isNull() || appliedThrough.isNull() || + *stableTimestamp == appliedThrough.getTimestamp(), + str::stream() << "Stable timestamp " << stableTimestamp->toString() + << " does not equal appliedThrough timestamp " + << appliedThrough.toString()); + } + // This may take an IS lock on the oplog collection. _truncateOplogIfNeededAndThenClearOplogTruncateAfterPoint(opCtx, stableTimestamp); diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp index 7eb258c5a8d..d80e7022582 100644 --- a/src/mongo/db/repl/replication_recovery_test.cpp +++ b/src/mongo/db/repl/replication_recovery_test.cpp @@ -695,6 +695,10 @@ TEST_F(ReplicationRecoveryTest, DEATH_TEST_F(ReplicationRecoveryTest, RecoveryFailsWithUnmatchedAppliedThrough, "Invariant failure") { + ASSERT_OK(ServerParameterSet::getGlobal() + ->getMap() + .find("assertStableTimestampEqualsAppliedThroughOnRecovery") + ->second->setFromString("true")); ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers()); auto opCtx = getOperationContext(); @@ -834,6 +838,10 @@ TEST_F(ReplicationRecoveryTest, RecoveryDoesNotApplyOperationsIfAppliedThroughIs DEATH_TEST_F(ReplicationRecoveryTest, RecoveryInvariantsWithUnequalStableTimestampAndAppliedThrough, "Invariant failure") { + ASSERT_OK(ServerParameterSet::getGlobal() + ->getMap() + .find("assertStableTimestampEqualsAppliedThroughOnRecovery") + ->second->setFromString("true")); ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers()); auto opCtx = getOperationContext(); diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index 5c4ac4ee515..0f0e1057835 100644 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -1265,6 +1265,14 @@ function appendSetParameterArgs(argArray) { continue; } + // Do not set this if test commands are not enabled or we are not on a new + // enough version. + if (paramName === "assertStableTimestampEqualsAppliedThroughOnRecovery" && + (!jsTest.options().enableTestCommands || + programMajorMinorVersion < 404)) { + continue; + } + const paramVal = ((param) => { if (typeof param === "object") { return JSON.stringify(param); |