summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
diff options
context:
space:
mode:
authorIan Boros <ian.boros@mongodb.com>2021-09-17 16:11:21 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-11 16:45:26 +0000
commit8f5ca6e3ce7153455a667e520478118e14e3beda (patch)
tree47a2dfd626895970c8cf4defc8ab7a9a33279f16 /src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
parent425083c4a584b6d321ec692eab66927ee564357c (diff)
downloadmongo-8f5ca6e3ce7153455a667e520478118e14e3beda.tar.gz
SERVER-60024 Add interface to recovery unit to force commit txn call
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
index a6cb4495b12..9e1c60377f3 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
@@ -815,6 +815,44 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, MultiTimestampConstraintsInternalState
ru1->commitUnitOfWork();
}
+TEST_F(WiredTigerRecoveryUnitTestFixture, AbandonSnapshotAbortMode) {
+ ru1->setAbandonSnapshotMode(RecoveryUnit::AbandonSnapshotMode::kAbort);
+
+ OperationContext* opCtx = clientAndCtx1.second.get();
+ const char* const key = "key";
+
+ {
+ ru1->beginUnitOfWork(opCtx);
+
+ WT_CURSOR* cursor;
+ getCursor(ru1, &cursor);
+ cursor->set_key(cursor, key);
+ cursor->set_value(cursor, "value");
+ invariantWTOK(wiredTigerCursorInsert(opCtx, cursor));
+
+ ru1->commitUnitOfWork();
+ }
+
+ // Create a cursor. We will check that once positioned, the cursor is reset by a call to
+ // abandonSnapshot() on the associated RecoveryUnit.
+ WT_CURSOR* cursor;
+ getCursor(ru1, &cursor);
+ cursor->set_key(cursor, key);
+ ASSERT_EQ(0, cursor->search(cursor));
+
+ ru1->abandonSnapshot();
+
+ // The WT transaction should have been aborted and the cursor reset.
+
+ // Advancing to the "next" record now that the cursor has been reset should give us the first
+ // record again.
+ ASSERT_EQ(0, cursor->next(cursor));
+
+ const char* returnedKey = nullptr;
+ ASSERT_EQ(0, cursor->get_key(cursor, &returnedKey));
+ ASSERT_EQ(0, strncmp(key, returnedKey, strlen(key)));
+}
+
DEATH_TEST_REGEX_F(WiredTigerRecoveryUnitTestFixture,
MultiTimestampConstraints,
"Fatal assertion.*4877100") {