summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2021-04-07 10:00:06 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-07 14:38:23 +0000
commite59d95b4dc565bade90426730a9415bc9be50e07 (patch)
treebec5f7f225ea60393ead02a28e300d9bfc03e286 /src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
parentbb6b69cd9223649aa27d67cd9a157e7e199e0f03 (diff)
downloadmongo-e59d95b4dc565bade90426730a9415bc9be50e07.tar.gz
Revert "SERVER-55342 Clustered collections should reject duplicate _id values"
This reverts commit 8cdac63ac18aa2e852d7450885fef71113ff0464.
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.cpp92
1 files changed, 6 insertions, 86 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 86f84e8f7f4..5c384c2b8ed 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
@@ -98,7 +98,6 @@ public:
params.engineName = kWiredTigerEngineName;
params.isCapped = false;
params.keyFormat = KeyFormat::Long;
- params.overwrite = true;
params.isEphemeral = false;
params.cappedCallback = nullptr;
params.sizeStorer = nullptr;
@@ -615,7 +614,7 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, CommitTimestampAfterSetTimestampOnAbor
ASSERT(!commitTs);
}
-TEST_F(WiredTigerRecoveryUnitTestFixture, ReadOnceCursorsCached) {
+TEST_F(WiredTigerRecoveryUnitTestFixture, ReadOnceCursorsAreNotCached) {
auto opCtx = clientAndCtx1.second.get();
// Hold the global lock throughout the test to avoid having the global lock destructor
@@ -649,8 +648,7 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, ReadOnceCursorsCached) {
ru->abandonSnapshot();
- // Test 2: A read-once operation should create a new cursor because it has a different
- // configuration. This will be released into the cache.
+ // Test 2: A read-once operation should create a new cursor and immediately close it when done.
ru->setReadOnce(true);
@@ -658,96 +656,18 @@ TEST_F(WiredTigerRecoveryUnitTestFixture, ReadOnceCursorsCached) {
ru->getSession()->closeAllCursors(uri);
cachedCursorsBefore = ru->getSession()->cachedCursors();
- // The subsequent read operation will create a new read_once cursor and release into the cache.
+ // The subsequent read operation will use a read_once cursor, which will not be from the cache,
+ // and will not be released into the cache.
ASSERT_TRUE(rs->findRecord(opCtx, s.getValue(), &rd));
- // A new cursor should have been released into the cache.
- ASSERT_GT(ru->getSession()->cachedCursors(), cachedCursorsBefore);
+ // No new cursors should have been released into the cache.
+ ASSERT_EQ(ru->getSession()->cachedCursors(), cachedCursorsBefore);
// All opened cursors are closed.
ASSERT_EQ(0, ru->getSession()->cursorsOut());
ASSERT(ru->getReadOnce());
}
-TEST_F(WiredTigerRecoveryUnitTestFixture, CacheMixedOverwrite) {
- auto opCtx = clientAndCtx1.second.get();
- std::unique_ptr<RecordStore> rs(harnessHelper->createRecordStore(opCtx, "test.A"));
- auto uri = dynamic_cast<WiredTigerRecordStore*>(rs.get())->getURI();
-
- // Hold the global lock throughout the test to avoid having the global lock destructor
- // prematurely abandon snapshots.
- Lock::GlobalLock globalLock(opCtx, MODE_IX);
- auto ru = WiredTigerRecoveryUnit::get(opCtx);
-
- // Close all cached cursors to establish a 'before' state.
- auto session = ru->getSession();
- ru->getSession()->closeAllCursors(uri);
- int cachedCursorsBefore = ru->getSession()->cachedCursors();
-
- // Use a large, unused table ID for this test to ensure we don't collide with any other table
- // ids.
- int tableId = 999999999;
- WT_CURSOR* cursor;
-
- // Expect no cached cursors.
- {
- auto config = "";
- cursor = session->getCachedCursor(tableId, config);
- ASSERT_FALSE(cursor);
-
- cursor = session->getNewCursor(uri, config);
- ASSERT(cursor);
- session->releaseCursor(tableId, cursor, config);
- ASSERT_GT(session->cachedCursors(), cachedCursorsBefore);
- }
-
- cachedCursorsBefore = session->cachedCursors();
-
- // Use a different overwrite setting, expect no cached cursors.
- {
- auto config = "overwrite=false";
- cursor = session->getCachedCursor(tableId, config);
- ASSERT_FALSE(cursor);
-
- cursor = session->getNewCursor(uri, config);
- ASSERT(cursor);
- session->releaseCursor(tableId, cursor, config);
- ASSERT_GT(session->cachedCursors(), cachedCursorsBefore);
- }
-
- cachedCursorsBefore = session->cachedCursors();
-
- // Expect cursors to be cached.
- {
- auto config = "";
- cursor = session->getCachedCursor(tableId, config);
- ASSERT(cursor);
- session->releaseCursor(tableId, cursor, config);
- ASSERT_EQ(session->cachedCursors(), cachedCursorsBefore);
- }
-
- // Expect cursors to be cached.
- {
- auto config = "overwrite=false";
- cursor = session->getCachedCursor(tableId, config);
- ASSERT(cursor);
- session->releaseCursor(tableId, cursor, config);
- ASSERT_EQ(session->cachedCursors(), cachedCursorsBefore);
- }
-
- // Use yet another cursor config, and expect no cursors to be cached.
- {
- auto config = "overwrite=true";
- cursor = session->getCachedCursor(tableId, config);
- ASSERT_FALSE(cursor);
-
- cursor = session->getNewCursor(uri, config);
- ASSERT(cursor);
- session->releaseCursor(tableId, cursor, config);
- ASSERT_GT(session->cachedCursors(), cachedCursorsBefore);
- }
-}
-
TEST_F(WiredTigerRecoveryUnitTestFixture, CommitWithDurableTimestamp) {
auto opCtx = clientAndCtx1.second.get();
Timestamp ts1(3, 3);