diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2023-02-07 14:44:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-07 16:32:19 +0000 |
commit | 50437919c2892e44c4afac4b0047952a9046829c (patch) | |
tree | 773f9ca6dee3b3483de9c9fcbccd4111b69eeb1c /src/mongo/db/catalog/collection_catalog_test.cpp | |
parent | 5b1a7a5cbe024b7bb123abb91020eb9997120259 (diff) | |
download | mongo-50437919c2892e44c4afac4b0047952a9046829c.tar.gz |
SERVER-59913 Move CollectionPtr yield logic out of the CollectionCatalog
CollectionPtr is no longer yieldable by default, to make them yieldable you must explicitly call 'makeYieldable'.
This removes some dependencies from the CollectionCatalog and allows us to set up how yielding should work in the AutoGet layer. This could also be a stepping stone to completely remove CollectionPtr from the interfaces of CollectionCatalog.
Diffstat (limited to 'src/mongo/db/catalog/collection_catalog_test.cpp')
-rw-r--r-- | src/mongo/db/catalog/collection_catalog_test.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp index 5c3563e6b69..5d31306de97 100644 --- a/src/mongo/db/catalog/collection_catalog_test.cpp +++ b/src/mongo/db/catalog/collection_catalog_test.cpp @@ -34,6 +34,7 @@ #include "mongo/db/catalog/catalog_test_fixture.h" #include "mongo/db/catalog/collection_catalog_helper.h" #include "mongo/db/catalog/collection_mock.h" +#include "mongo/db/catalog/collection_yield_restore.h" #include "mongo/db/catalog/uncommitted_catalog_updates.h" #include "mongo/db/catalog_raii.h" #include "mongo/db/concurrency/lock_manager_defs.h" @@ -75,7 +76,7 @@ public: globalLock.emplace(opCtx.get()); std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(colUUID, nss); - col = CollectionPtr(collection.get(), CollectionPtr::NoYieldTag{}); + col = CollectionPtr(collection.get()); // Register dummy collection in catalog. catalog.registerCollection(opCtx.get(), colUUID, collection, boost::none); @@ -354,6 +355,10 @@ TEST_F(CollectionCatalogTest, OnDropCollection) { ASSERT(yieldableColl); ASSERT_EQUALS(yieldableColl, col); + // Make the CollectionPtr yieldable by setting yield impl + yieldableColl.makeYieldable(opCtx.get(), + LockedCollectionYieldRestore(opCtx.get(), yieldableColl)); + // Yielding resets a CollectionPtr's internal state to be restored later, provided // the collection has not been dropped or renamed. ASSERT_EQ(yieldableColl->uuid(), colUUID); // Correct collection UUID is required for restore. @@ -392,6 +397,10 @@ TEST_F(CollectionCatalogTest, RenameCollection) { ASSERT(yieldableColl); ASSERT_EQUALS(yieldableColl, collection); + // Make the CollectionPtr yieldable by setting yield impl + yieldableColl.makeYieldable(opCtx.get(), + LockedCollectionYieldRestore(opCtx.get(), yieldableColl)); + // Yielding resets a CollectionPtr's internal state to be restored later, provided // the collection has not been dropped or renamed. ASSERT_EQ(yieldableColl->uuid(), uuid); // Correct collection UUID is required for restore. |