summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_recovery_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/replication_recovery_test.cpp')
-rw-r--r--src/mongo/db/repl/replication_recovery_test.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp
index 00bd8b1c35b..2306994463a 100644
--- a/src/mongo/db/repl/replication_recovery_test.cpp
+++ b/src/mongo/db/repl/replication_recovery_test.cpp
@@ -702,7 +702,7 @@ TEST_F(ReplicationRecoveryTest,
testRecoveryToStableAppliesDocumentsWithNoAppliedThrough(false);
}
-TEST_F(ReplicationRecoveryTest, RecoveryIgnoresDroppedCollections) {
+TEST_F(ReplicationRecoveryTest, UnstableRecoveryIgnoresDroppedCollections) {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -714,7 +714,7 @@ TEST_F(ReplicationRecoveryTest, RecoveryIgnoresDroppedCollections) {
ASSERT_FALSE(autoColl.getCollection());
}
- getStorageInterfaceRecovery()->setRecoveryTimestamp(Timestamp(2, 2));
+ // Not setting a stable timestamp in order to perform unstable recovery,
recovery.recoverFromOplog(opCtx, boost::none);
_assertDocsInOplog(opCtx, {1, 2, 3, 4, 5});
@@ -725,6 +725,24 @@ TEST_F(ReplicationRecoveryTest, RecoveryIgnoresDroppedCollections) {
ASSERT_EQ(getConsistencyMarkers()->getOplogTruncateAfterPoint(opCtx), Timestamp());
}
+DEATH_TEST_REGEX_F(ReplicationRecoveryTest,
+ StableRecoveryCrashOnDroppedCollectionsInTests,
+ "Fatal assertion.*5415000") {
+ ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
+ auto opCtx = getOperationContext();
+
+ _setUpOplog(opCtx, getStorageInterface(), {1, 2, 3, 4, 5});
+
+ ASSERT_OK(getStorageInterface()->dropCollection(opCtx, testNs));
+ {
+ AutoGetCollectionForReadCommand autoColl(opCtx, testNs);
+ ASSERT_FALSE(autoColl.getCollection());
+ }
+
+ getStorageInterfaceRecovery()->setRecoveryTimestamp(Timestamp(2, 2));
+ recovery.recoverFromOplog(opCtx, boost::none);
+}
+
TEST_F(ReplicationRecoveryTest, RecoveryAppliesDocumentsWhenAppliedThroughIsBehindAfterTruncation) {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1212,7 +1230,7 @@ TEST_F(ReplicationRecoveryTest,
ASSERT_EQ(getConsistencyMarkers()->getOplogTruncateAfterPoint(opCtx), Timestamp());
}
-TEST_F(ReplicationRecoveryTest, RecoverFromOplogUpToBeforeEndOfOplog) {
+TEST_F(ReplicationRecoveryTest, RecoverFromOplogUpTo) {
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
@@ -1222,8 +1240,16 @@ TEST_F(ReplicationRecoveryTest, RecoverFromOplogUpToBeforeEndOfOplog) {
// Recovers operations with timestamps: 3, 4, 5.
recovery.recoverFromOplogUpTo(opCtx, Timestamp(5, 5));
_assertDocsInTestCollection(opCtx, {3, 4, 5});
+}
+
+TEST_F(ReplicationRecoveryTest, RecoverFromOplogUpToBeforeEndOfOplog) {
+ ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
+ auto opCtx = getOperationContext();
- // Recovers operations with timestamps: 6, 7, 8, 9.
+ _setUpOplog(opCtx, getStorageInterface(), {2, 3, 4, 5, 6, 7, 8, 9, 10});
+ getStorageInterfaceRecovery()->setRecoveryTimestamp(Timestamp(2, 2));
+
+ // Recovers operations with timestamps: 3, 4, 5, 6, 7, 8, 9.
recovery.recoverFromOplogUpTo(opCtx, Timestamp(9, 9));
_assertDocsInTestCollection(opCtx, {3, 4, 5, 6, 7, 8, 9});
}
@@ -1289,8 +1315,6 @@ TEST_F(ReplicationRecoveryTest, RecoverFromOplogUpToDoesNotExceedEndPoint) {
_setUpOplog(opCtx, getStorageInterface(), {2, 5, 10});
getStorageInterfaceRecovery()->setRecoveryTimestamp(Timestamp(2, 2));
- recovery.recoverFromOplogUpTo(opCtx, Timestamp(9, 9));
-
recovery.recoverFromOplogUpTo(opCtx, Timestamp(15, 15));
}