diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-08-31 15:39:53 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-15 14:28:38 +0000 |
commit | accc7e7cd7e7a984347361d03ee76514c4a54163 (patch) | |
tree | d01b140af8d8609d19ed1b5f5126511bc06377e3 /src/mongo/db/catalog/collection_catalog_test.cpp | |
parent | b3f2165c7cf7d2e4d098f86eaf8bfa3b87b683a1 (diff) | |
download | mongo-accc7e7cd7e7a984347361d03ee76514c4a54163.tar.gz |
SERVER-50349 Getting a writable collection now requires the caller to be inside a WUOW by default
There are three modes when accessing a writable Collection:
* Managed in WUOW (default)
* Unmanaged (users need to commit/rollback)
* Inplace that provides direct access to the Collection in the catalog. (Users need to ensure there's no concurrent operations going on)
Added a helper RAII type CollectionWriter that abstract the three modes above and also provides abstraction on different methods of accessing Collections (AutoGetCollection or manual lookups).
Writable Collection is aquired lazily when needed (usually inside a WUOW).
Diffstat (limited to 'src/mongo/db/catalog/collection_catalog_test.cpp')
-rw-r--r-- | src/mongo/db/catalog/collection_catalog_test.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp index 3e5f1e906e9..5ac89ed76a8 100644 --- a/src/mongo/db/catalog/collection_catalog_test.cpp +++ b/src/mongo/db/catalog/collection_catalog_test.cpp @@ -655,7 +655,8 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNamesWithUncommitt } // One dbName with only an invisible collection does not appear in dbNames. - auto invisibleCollA = catalog.lookupCollectionByNamespaceForMetadataWrite(&opCtx, aColl); + auto invisibleCollA = catalog.lookupCollectionByNamespaceForMetadataWrite( + &opCtx, CollectionCatalog::LifetimeMode::kInplace, aColl); invisibleCollA->setCommitted(false); auto res = catalog.getAllCollectionNamesFromDb(&opCtx, "dbA"); @@ -672,7 +673,8 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNamesWithUncommitt std::vector<NamespaceString> dCollList = dbDNss; dCollList.erase(std::find(dCollList.begin(), dCollList.end(), nss)); - auto invisibleCollD = catalog.lookupCollectionByNamespaceForMetadataWrite(&opCtx, nss); + auto invisibleCollD = catalog.lookupCollectionByNamespaceForMetadataWrite( + &opCtx, CollectionCatalog::LifetimeMode::kInplace, nss); invisibleCollD->setCommitted(false); res = catalog.getAllCollectionNamesFromDb(&opCtx, "dbD"); @@ -687,7 +689,8 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNamesWithUncommitt // If all dbNames consist only of invisible collections, none of these dbs is visible. for (auto& nss : nsss) { - auto invisibleColl = catalog.lookupCollectionByNamespaceForMetadataWrite(&opCtx, nss); + auto invisibleColl = catalog.lookupCollectionByNamespaceForMetadataWrite( + &opCtx, CollectionCatalog::LifetimeMode::kInplace, nss); invisibleColl->setCommitted(false); } |