diff options
author | Daniel Gómez Ferro <daniel.gomezferro@mongodb.com> | 2021-11-26 14:39:47 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-02 09:08:59 +0000 |
commit | a51938f6f77a6c4934c0cc91bca31cebb6af62e5 (patch) | |
tree | c6ad3f87cc216930c8707fdb9c7d3d2cfaf084cb /src/mongo | |
parent | c5f47b7a04ce688b088c1373805e876b0debae66 (diff) | |
download | mongo-a51938f6f77a6c4934c0cc91bca31cebb6af62e5.tar.gz |
SERVER-60837 Remove CollectionUUID and OptionalCollectionUUID aliases
Diffstat (limited to 'src/mongo')
93 files changed, 446 insertions, 486 deletions
diff --git a/src/mongo/db/auth/auth_op_observer.cpp b/src/mongo/db/auth/auth_op_observer.cpp index 729493ed970..325b9f99fb4 100644 --- a/src/mongo/db/auth/auth_op_observer.cpp +++ b/src/mongo/db/auth/auth_op_observer.cpp @@ -164,7 +164,7 @@ void AuthOpObserver::postRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) { const auto cmdNss = fromCollection.getCommandNS(); @@ -186,7 +186,7 @@ void AuthOpObserver::onRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { postRenameCollection(opCtx, fromCollection, toCollection, uuid, dropTargetUUID, stayTemp); diff --git a/src/mongo/db/auth/auth_op_observer.h b/src/mongo/db/auth/auth_op_observer.h index b921c67519f..5bf86445b7a 100644 --- a/src/mongo/db/auth/auth_op_observer.h +++ b/src/mongo/db/auth/auth_op_observer.h @@ -47,13 +47,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} @@ -64,14 +64,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -99,7 +99,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -141,7 +141,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final; @@ -159,7 +159,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final { return repl::OpTime(); @@ -168,7 +168,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final; void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h index 37b75b0a657..7ecc9e7bf08 100644 --- a/src/mongo/db/catalog/collection.h +++ b/src/mongo/db/catalog/collection.h @@ -817,7 +817,7 @@ public: // Function for the implementation on how we load a new Collection pointer when restoring from // yield - using RestoreFn = std::function<const Collection*(OperationContext*, CollectionUUID)>; + using RestoreFn = std::function<const Collection*(OperationContext*, UUID)>; CollectionPtr(); diff --git a/src/mongo/db/catalog/collection_catalog.cpp b/src/mongo/db/catalog/collection_catalog.cpp index f1a1097548f..124367b7148 100644 --- a/src/mongo/db/catalog/collection_catalog.cpp +++ b/src/mongo/db/catalog/collection_catalog.cpp @@ -71,7 +71,7 @@ public: kRecreated }; - CollectionUUID uuid() const { + UUID uuid() const { if (action == Action::kDropped || action == Entry::Action::kRecreated) return *externalUUID; return collection->uuid(); @@ -103,7 +103,7 @@ public: * A managed Collection pointer may be returned as nullptr, which indicates a drop. * If the returned boolean is false then the Collection will always be nullptr. */ - std::pair<bool, Collection*> lookup(CollectionUUID uuid) const { + std::pair<bool, Collection*> lookup(UUID uuid) const { // Doing reverse search so we find most recent entry affecting this uuid auto it = std::find_if(_entries.rbegin(), _entries.rend(), [uuid](auto&& entry) { // Rename actions don't have UUID @@ -188,7 +188,7 @@ public: /** * Re-creates a collection that has previously been dropped */ - void createAfterDrop(CollectionUUID uuid, std::shared_ptr<Collection> collection) { + void createAfterDrop(UUID uuid, std::shared_ptr<Collection> collection) { const auto& ns = collection->ns(); _entries.push_back({Entry::Action::kRecreated, std::move(collection), ns, uuid}); } @@ -328,10 +328,10 @@ CollectionCatalog::iterator::iterator(OperationContext* opCtx, } } -CollectionCatalog::iterator::iterator(OperationContext* opCtx, - std::map<std::pair<std::string, CollectionUUID>, - std::shared_ptr<Collection>>::const_iterator mapIter, - const CollectionCatalog& catalog) +CollectionCatalog::iterator::iterator( + OperationContext* opCtx, + std::map<std::pair<std::string, UUID>, std::shared_ptr<Collection>>::const_iterator mapIter, + const CollectionCatalog& catalog) : _opCtx(opCtx), _mapIter(mapIter), _catalog(&catalog) {} CollectionCatalog::iterator::value_type CollectionCatalog::iterator::operator*() { @@ -348,7 +348,7 @@ Collection* CollectionCatalog::iterator::getWritableCollection(OperationContext* opCtx, mode, operator*()->uuid()); } -boost::optional<CollectionUUID> CollectionCatalog::iterator::uuid() { +boost::optional<UUID> CollectionCatalog::iterator::uuid() { return _uuid; } @@ -605,7 +605,7 @@ uint64_t CollectionCatalog::getEpoch() const { } std::shared_ptr<const Collection> CollectionCatalog::lookupCollectionByUUIDForRead( - OperationContext* opCtx, CollectionUUID uuid) const { + OperationContext* opCtx, const UUID& uuid) const { if (auto coll = UncommittedCollections::getForTxn(opCtx, uuid)) { return coll; } @@ -616,7 +616,7 @@ std::shared_ptr<const Collection> CollectionCatalog::lookupCollectionByUUIDForRe Collection* CollectionCatalog::lookupCollectionByUUIDForMetadataWrite(OperationContext* opCtx, LifetimeMode mode, - CollectionUUID uuid) const { + const UUID& uuid) const { if (mode == LifetimeMode::kInplace) { return const_cast<Collection*>(lookupCollectionByUUID(opCtx, uuid).get()); } @@ -653,8 +653,7 @@ Collection* CollectionCatalog::lookupCollectionByUUIDForMetadataWrite(OperationC return ptr; } -CollectionPtr CollectionCatalog::lookupCollectionByUUID(OperationContext* opCtx, - CollectionUUID uuid) const { +CollectionPtr CollectionCatalog::lookupCollectionByUUID(OperationContext* opCtx, UUID uuid) const { auto& uncommittedCatalogUpdates = getUncommittedCatalogUpdates(opCtx); auto [found, uncommittedPtr] = uncommittedCatalogUpdates.lookup(uuid); // If UUID is managed by uncommittedCatalogUpdates return the pointer which will be nullptr in @@ -674,12 +673,12 @@ CollectionPtr CollectionCatalog::lookupCollectionByUUID(OperationContext* opCtx, : CollectionPtr(); } -bool CollectionCatalog::isCollectionAwaitingVisibility(CollectionUUID uuid) const { +bool CollectionCatalog::isCollectionAwaitingVisibility(UUID uuid) const { auto coll = _lookupCollectionByUUID(uuid); return coll && !coll->isCommitted(); } -std::shared_ptr<Collection> CollectionCatalog::_lookupCollectionByUUID(CollectionUUID uuid) const { +std::shared_ptr<Collection> CollectionCatalog::_lookupCollectionByUUID(UUID uuid) const { auto foundIt = _catalog.find(uuid); return foundIt == _catalog.end() ? nullptr : foundIt->second; } @@ -766,7 +765,7 @@ CollectionPtr CollectionCatalog::lookupCollectionByNamespace(OperationContext* o } boost::optional<NamespaceString> CollectionCatalog::lookupNSSByUUID(OperationContext* opCtx, - CollectionUUID uuid) const { + const UUID& uuid) const { auto& uncommittedCatalogUpdates = getUncommittedCatalogUpdates(opCtx); auto [found, uncommittedPtr] = uncommittedCatalogUpdates.lookup(uuid); // If UUID is managed by uncommittedCatalogUpdates return its corresponding namespace if the @@ -800,8 +799,8 @@ boost::optional<NamespaceString> CollectionCatalog::lookupNSSByUUID(OperationCon return boost::none; } -boost::optional<CollectionUUID> CollectionCatalog::lookupUUIDByNSS( - OperationContext* opCtx, const NamespaceString& nss) const { +boost::optional<UUID> CollectionCatalog::lookupUUIDByNSS(OperationContext* opCtx, + const NamespaceString& nss) const { auto& uncommittedCatalogUpdates = getUncommittedCatalogUpdates(opCtx); auto [found, uncommittedPtr] = uncommittedCatalogUpdates.lookup(nss); if (uncommittedPtr) { @@ -818,7 +817,7 @@ boost::optional<CollectionUUID> CollectionCatalog::lookupUUIDByNSS( auto it = _collections.find(nss); if (it != _collections.end()) { - boost::optional<CollectionUUID> uuid = it->second->uuid(); + const boost::optional<UUID>& uuid = it->second->uuid(); return it->second->isCommitted() ? uuid : boost::none; } return boost::none; @@ -847,8 +846,7 @@ NamespaceString CollectionCatalog::resolveNamespaceStringOrUUID( return std::move(*resolvedNss); } -bool CollectionCatalog::checkIfCollectionSatisfiable(CollectionUUID uuid, - CollectionInfoFn predicate) const { +bool CollectionCatalog::checkIfCollectionSatisfiable(UUID uuid, CollectionInfoFn predicate) const { invariant(predicate); auto collection = _lookupCollectionByUUID(uuid); @@ -860,12 +858,11 @@ bool CollectionCatalog::checkIfCollectionSatisfiable(CollectionUUID uuid, return predicate(collection.get()); } -std::vector<CollectionUUID> CollectionCatalog::getAllCollectionUUIDsFromDb( - StringData dbName) const { +std::vector<UUID> CollectionCatalog::getAllCollectionUUIDsFromDb(StringData dbName) const { auto minUuid = UUID::parse("00000000-0000-0000-0000-000000000000").getValue(); auto it = _orderedCollections.lower_bound(std::make_pair(dbName.toString(), minUuid)); - std::vector<CollectionUUID> ret; + std::vector<UUID> ret; while (it != _orderedCollections.end() && it->first.first == dbName) { if (it->second->isCommitted()) { ret.push_back(it->first.second); @@ -944,7 +941,7 @@ CollectionCatalog::ViewCatalogSet CollectionCatalog::getViewCatalogDbNames() con } void CollectionCatalog::registerCollection(OperationContext* opCtx, - CollectionUUID uuid, + const UUID& uuid, std::shared_ptr<Collection> coll) { auto ns = coll->ns(); if (auto it = _views.find(ns.db()); it != _views.end()) { @@ -1006,7 +1003,7 @@ void CollectionCatalog::registerCollection(OperationContext* opCtx, } std::shared_ptr<Collection> CollectionCatalog::deregisterCollection(OperationContext* opCtx, - CollectionUUID uuid) { + const UUID& uuid) { invariant(_catalog.find(uuid) != _catalog.end()); auto coll = std::move(_catalog[uuid]); @@ -1195,7 +1192,7 @@ void CollectionCatalogStasher::reset() { } const Collection* LookupCollectionForYieldRestore::operator()(OperationContext* opCtx, - CollectionUUID uuid) const { + const UUID& uuid) const { auto collection = CollectionCatalog::get(opCtx)->lookupCollectionByUUID(opCtx, uuid).get(); if (!collection) return nullptr; diff --git a/src/mongo/db/catalog/collection_catalog.h b/src/mongo/db/catalog/collection_catalog.h index 459298b6e7c..413378233e0 100644 --- a/src/mongo/db/catalog/collection_catalog.h +++ b/src/mongo/db/catalog/collection_catalog.h @@ -41,11 +41,6 @@ namespace mongo { -/** - * This class comprises a UUID to collection catalog, allowing for efficient - * collection lookup by UUID. - */ -using CollectionUUID = UUID; class CollectionCatalog; class Database; @@ -75,13 +70,13 @@ public: iterator(OperationContext* opCtx, StringData dbName, const CollectionCatalog& catalog); iterator(OperationContext* opCtx, - std::map<std::pair<std::string, CollectionUUID>, - std::shared_ptr<Collection>>::const_iterator mapIter, + std::map<std::pair<std::string, UUID>, std::shared_ptr<Collection>>::const_iterator + mapIter, const CollectionCatalog& catalog); value_type operator*(); iterator operator++(); iterator operator++(int); - boost::optional<CollectionUUID> uuid(); + boost::optional<UUID> uuid(); Collection* getWritableCollection(OperationContext* opCtx, LifetimeMode mode); @@ -97,9 +92,9 @@ public: OperationContext* _opCtx; std::string _dbName; - boost::optional<CollectionUUID> _uuid; - std::map<std::pair<std::string, CollectionUUID>, - std::shared_ptr<Collection>>::const_iterator _mapIter; + boost::optional<UUID> _uuid; + std::map<std::pair<std::string, UUID>, std::shared_ptr<Collection>>::const_iterator + _mapIter; const CollectionCatalog* _catalog; }; @@ -174,13 +169,13 @@ public: * Register the collection with `uuid`. */ void registerCollection(OperationContext* opCtx, - CollectionUUID uuid, + const UUID& uuid, std::shared_ptr<Collection> collection); /** * Deregister the collection. */ - std::shared_ptr<Collection> deregisterCollection(OperationContext* opCtx, CollectionUUID uuid); + std::shared_ptr<Collection> deregisterCollection(OperationContext* opCtx, const UUID& uuid); /** * Deregister all the collection objects and view namespaces. @@ -207,7 +202,7 @@ public: void replaceViewsForDatabase(StringData dbName, absl::flat_hash_set<NamespaceString> views); /** - * This function gets the Collection pointer that corresponds to the CollectionUUID. + * This function gets the Collection pointer that corresponds to the UUID. * * The required locks must be obtained prior to calling this function, or else the found * Collection pointer might no longer be valid when the call returns. @@ -224,16 +219,16 @@ public: */ Collection* lookupCollectionByUUIDForMetadataWrite(OperationContext* opCtx, LifetimeMode mode, - CollectionUUID uuid) const; - CollectionPtr lookupCollectionByUUID(OperationContext* opCtx, CollectionUUID uuid) const; + const UUID& uuid) const; + CollectionPtr lookupCollectionByUUID(OperationContext* opCtx, UUID uuid) const; std::shared_ptr<const Collection> lookupCollectionByUUIDForRead(OperationContext* opCtx, - CollectionUUID uuid) const; + const UUID& uuid) const; /** * Returns true if the collection has been registered in the CollectionCatalog but not yet made * visible. */ - bool isCollectionAwaitingVisibility(CollectionUUID uuid) const; + bool isCollectionAwaitingVisibility(UUID uuid) const; /** * These functions fetch a Collection pointer that corresponds to the NamespaceString. @@ -261,17 +256,17 @@ public: /** * This function gets the NamespaceString from the collection catalog entry that - * corresponds to CollectionUUID uuid. If no collection exists with the uuid, return + * corresponds to UUID uuid. If no collection exists with the uuid, return * boost::none. See onCloseCatalog/onOpenCatalog for more info. */ boost::optional<NamespaceString> lookupNSSByUUID(OperationContext* opCtx, - CollectionUUID uuid) const; + const UUID& uuid) const; /** * Returns the UUID if `nss` exists in CollectionCatalog. */ - boost::optional<CollectionUUID> lookupUUIDByNSS(OperationContext* opCtx, - const NamespaceString& nss) const; + boost::optional<UUID> lookupUUIDByNSS(OperationContext* opCtx, + const NamespaceString& nss) const; /** * Without acquiring any locks resolves the given NamespaceStringOrUUID to an actual namespace. @@ -285,7 +280,7 @@ public: * Returns whether the collection with 'uuid' satisfies the provided 'predicate'. If the * collection with 'uuid' is not found, false is returned. */ - bool checkIfCollectionSatisfiable(CollectionUUID uuid, CollectionInfoFn predicate) const; + bool checkIfCollectionSatisfiable(UUID uuid, CollectionInfoFn predicate) const; /** * This function gets the UUIDs of all collections from `dbName`. @@ -295,7 +290,7 @@ public: * * Returns empty vector if the 'dbName' is not known. */ - std::vector<CollectionUUID> getAllCollectionUUIDsFromDb(StringData dbName) const; + std::vector<UUID> getAllCollectionUUIDsFromDb(StringData dbName) const; /** * This function gets the ns of all collections from `dbName`. The result is not sorted. @@ -421,20 +416,17 @@ private: friend class CollectionCatalog::iterator; class PublishCatalogUpdates; - std::shared_ptr<Collection> _lookupCollectionByUUID(CollectionUUID uuid) const; + std::shared_ptr<Collection> _lookupCollectionByUUID(UUID uuid) const; /** * When present, indicates that the catalog is in closed state, and contains a map from UUID * to pre-close NSS. See also onCloseCatalog. */ - boost::optional< - mongo::stdx::unordered_map<CollectionUUID, NamespaceString, CollectionUUID::Hash>> - _shadowCatalog; + boost::optional<mongo::stdx::unordered_map<UUID, NamespaceString, UUID::Hash>> _shadowCatalog; - using CollectionCatalogMap = - stdx::unordered_map<CollectionUUID, std::shared_ptr<Collection>, CollectionUUID::Hash>; + using CollectionCatalogMap = stdx::unordered_map<UUID, std::shared_ptr<Collection>, UUID::Hash>; using OrderedCollectionMap = - std::map<std::pair<std::string, CollectionUUID>, std::shared_ptr<Collection>>; + std::map<std::pair<std::string, UUID>, std::shared_ptr<Collection>>; using NamespaceCollectionMap = stdx::unordered_map<NamespaceString, std::shared_ptr<Collection>>; using DatabaseProfileSettingsMap = StringMap<ProfileSettings>; @@ -519,7 +511,7 @@ private: * restore implementation for CollectionPtr when acquired from the catalog. */ struct LookupCollectionForYieldRestore { - const Collection* operator()(OperationContext* opCtx, CollectionUUID uuid) const; + const Collection* operator()(OperationContext* opCtx, const UUID& uuid) const; }; /** diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp index 031421c990a..d50d8be1f3c 100644 --- a/src/mongo/db/catalog/collection_catalog_test.cpp +++ b/src/mongo/db/catalog/collection_catalog_test.cpp @@ -51,9 +51,9 @@ public: CollectionCatalogTest() : nss("testdb", "testcol"), col(nullptr), - colUUID(CollectionUUID::gen()), - nextUUID(CollectionUUID::gen()), - prevUUID(CollectionUUID::gen()) { + colUUID(UUID::gen()), + nextUUID(UUID::gen()), + prevUUID(UUID::gen()) { if (prevUUID > colUUID) std::swap(prevUUID, colUUID); if (colUUID > nextUUID) @@ -79,9 +79,9 @@ protected: ServiceContext::UniqueOperationContext opCtx; NamespaceString nss; CollectionPtr col; - CollectionUUID colUUID; - CollectionUUID nextUUID; - CollectionUUID prevUUID; + UUID colUUID; + UUID nextUUID; + UUID prevUUID; }; class CollectionCatalogIterationTest : public unittest::Test { @@ -91,10 +91,10 @@ public: NamespaceString fooNss("foo", "coll" + std::to_string(counter)); NamespaceString barNss("bar", "coll" + std::to_string(counter)); - auto fooUuid = CollectionUUID::gen(); + auto fooUuid = UUID::gen(); std::shared_ptr<Collection> fooColl = std::make_shared<CollectionMock>(fooNss); - auto barUuid = CollectionUUID::gen(); + auto barUuid = UUID::gen(); std::shared_ptr<Collection> barColl = std::make_shared<CollectionMock>(barNss); dbMap["foo"].insert(std::make_pair(fooUuid, fooColl.get())); @@ -112,13 +112,13 @@ public: } } - std::map<CollectionUUID, CollectionPtr>::iterator collsIterator(std::string dbName) { + std::map<UUID, CollectionPtr>::iterator collsIterator(std::string dbName) { auto it = dbMap.find(dbName); ASSERT(it != dbMap.end()); return it->second.begin(); } - std::map<CollectionUUID, CollectionPtr>::iterator collsIteratorEnd(std::string dbName) { + std::map<UUID, CollectionPtr>::iterator collsIteratorEnd(std::string dbName) { auto it = dbMap.find(dbName); ASSERT(it != dbMap.end()); return it->second.end(); @@ -142,14 +142,14 @@ public: ASSERT_EQUALS(counter, dbMap[dbName].size()); } - void dropColl(const std::string dbName, CollectionUUID uuid) { + void dropColl(const std::string dbName, UUID uuid) { dbMap[dbName].erase(uuid); } protected: CollectionCatalog catalog; OperationContextNoop opCtx; - std::map<std::string, std::map<CollectionUUID, CollectionPtr>> dbMap; + std::map<std::string, std::map<UUID, CollectionPtr>> dbMap; }; class CollectionCatalogResourceMapTest : public unittest::Test { @@ -294,7 +294,7 @@ public: } void tearDown() { - std::vector<CollectionUUID> collectionsToDeregister; + std::vector<UUID> collectionsToDeregister; for (auto it = catalog.begin(&opCtx, "resourceDb"); it != catalog.end(&opCtx); ++it) { auto coll = *it; auto uuid = coll->uuid(); @@ -405,18 +405,18 @@ TEST_F(CollectionCatalogTest, LookupCollectionByUUID) { // nss.ns(). ASSERT_EQUALS(catalog.lookupCollectionByUUID(opCtx.get(), colUUID)->ns().ns(), nss.ns()); // Ensure lookups of unknown UUIDs result in null pointers. - ASSERT(catalog.lookupCollectionByUUID(opCtx.get(), CollectionUUID::gen()) == nullptr); + ASSERT(catalog.lookupCollectionByUUID(opCtx.get(), UUID::gen()) == nullptr); } TEST_F(CollectionCatalogTest, LookupNSSByUUID) { // Ensure the string value of the obtained NamespaceString is equal to nss.ns(). ASSERT_EQUALS(catalog.lookupNSSByUUID(opCtx.get(), colUUID)->ns(), nss.ns()); // Ensure namespace lookups of unknown UUIDs result in empty NamespaceStrings. - ASSERT_EQUALS(catalog.lookupNSSByUUID(opCtx.get(), CollectionUUID::gen()), boost::none); + ASSERT_EQUALS(catalog.lookupNSSByUUID(opCtx.get(), UUID::gen()), boost::none); } TEST_F(CollectionCatalogTest, InsertAfterLookup) { - auto newUUID = CollectionUUID::gen(); + auto newUUID = UUID::gen(); NamespaceString newNss(nss.db(), "newcol"); std::shared_ptr<Collection> newCollShared = std::make_shared<CollectionMock>(newNss); auto newCol = newCollShared.get(); @@ -436,7 +436,7 @@ TEST_F(CollectionCatalogTest, OnDropCollection) { } TEST_F(CollectionCatalogTest, RenameCollection) { - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); NamespaceString oldNss(nss.db(), "oldcol"); std::shared_ptr<Collection> collShared = std::make_shared<CollectionMock>(oldNss); auto collection = collShared.get(); @@ -468,7 +468,7 @@ TEST_F(CollectionCatalogTest, LookupNSSByUUIDForClosedCatalogReturnsOldNSSIfDrop } TEST_F(CollectionCatalogTest, LookupNSSByUUIDForClosedCatalogReturnsNewlyCreatedNSS) { - auto newUUID = CollectionUUID::gen(); + auto newUUID = UUID::gen(); NamespaceString newNss(nss.db(), "newcol"); std::shared_ptr<Collection> newCollShared = std::make_shared<CollectionMock>(newNss); auto newCol = newCollShared.get(); @@ -553,7 +553,7 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNames) { std::vector<NamespaceString> nsss = {aColl, b1Coll, b2Coll, cColl, d1Coll, d2Coll, d3Coll}; for (auto& nss : nsss) { std::shared_ptr<Collection> newColl = std::make_shared<CollectionMock>(nss); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); catalog.registerCollection(opCtx.get(), uuid, std::move(newColl)); } @@ -604,7 +604,7 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNamesWithUncommitt std::vector<NamespaceString> nsss = {aColl, b1Coll, b2Coll, cColl, d1Coll, d2Coll, d3Coll}; for (auto& nss : nsss) { std::shared_ptr<Collection> newColl = std::make_shared<CollectionMock>(nss); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); catalog.registerCollection(opCtx.get(), uuid, std::move(newColl)); } diff --git a/src/mongo/db/catalog/collection_options.cpp b/src/mongo/db/catalog/collection_options.cpp index cb9c665f5d7..42fdffb2616 100644 --- a/src/mongo/db/catalog/collection_options.cpp +++ b/src/mongo/db/catalog/collection_options.cpp @@ -91,7 +91,7 @@ StatusWith<CollectionOptions> CollectionOptions::parse(const BSONObj& options, P StringData fieldName = e.fieldName(); if (fieldName == "uuid" && kind == parseForStorage) { - auto res = CollectionUUID::parse(e); + auto res = UUID::parse(e); if (!res.isOK()) { return res.getStatus(); } diff --git a/src/mongo/db/catalog/collection_options.h b/src/mongo/db/catalog/collection_options.h index 5c2d179d69c..52e0506bc43 100644 --- a/src/mongo/db/catalog/collection_options.h +++ b/src/mongo/db/catalog/collection_options.h @@ -46,17 +46,6 @@ namespace mongo { class CollatorFactoryInterface; class CreateCommand; -/** - * A CollectionUUID is a 128-bit unique identifier, per RFC 4122, v4. for a database collection. - * Newly created collections are assigned a new randomly generated CollectionUUID. In a replica-set - * or a sharded cluster, all nodes will use the same UUID for a given collection. The UUID stays - * with the collection until it is dropped, so even across renames. A copied collection must have - * its own new unique UUID though. - */ -using CollectionUUID = UUID; - -using OptionalCollectionUUID = boost::optional<CollectionUUID>; - struct CollectionOptions { /** * Returns true if the options indicate the namespace is a view. @@ -114,7 +103,7 @@ struct CollectionOptions { // Collection UUID. If not set, specifies that the storage engine should generate the UUID (for // a new collection). For an existing collection parsed for storage, it will always be present. - OptionalCollectionUUID uuid; + boost::optional<UUID> uuid; bool capped = false; long long cappedSize = 0; diff --git a/src/mongo/db/catalog/collection_options_test.cpp b/src/mongo/db/catalog/collection_options_test.cpp index 2c08e0c6952..385310f4f87 100644 --- a/src/mongo/db/catalog/collection_options_test.cpp +++ b/src/mongo/db/catalog/collection_options_test.cpp @@ -300,7 +300,7 @@ TEST(CollectionOptions, WriteConcernAllowlistedOptionIgnored) { TEST(CollectionOptions, ParseUUID) { CollectionOptions options; - CollectionUUID uuid = CollectionUUID::gen(); + UUID uuid = UUID::gen(); // Check required parse failures ASSERT_FALSE(options.uuid); diff --git a/src/mongo/db/catalog/collection_test.cpp b/src/mongo/db/catalog/collection_test.cpp index 6480eef202b..a95c7a9b93f 100644 --- a/src/mongo/db/catalog/collection_test.cpp +++ b/src/mongo/db/catalog/collection_test.cpp @@ -488,12 +488,11 @@ TEST_F(CatalogTestFixture, CollectionPtrYieldable) { int numRestoreCalls = 0; - CollectionPtr coll(operationContext(), - &beforeYield, - [&afterYield, &numRestoreCalls](OperationContext*, CollectionUUID) { - ++numRestoreCalls; - return &afterYield; - }); + CollectionPtr coll( + operationContext(), &beforeYield, [&afterYield, &numRestoreCalls](OperationContext*, UUID) { + ++numRestoreCalls; + return &afterYield; + }); ASSERT_TRUE(coll); ASSERT_EQ(coll.get(), &beforeYield); diff --git a/src/mongo/db/catalog/collection_writer_test.cpp b/src/mongo/db/catalog/collection_writer_test.cpp index f1d74c2e354..8401082bbec 100644 --- a/src/mongo/db/catalog/collection_writer_test.cpp +++ b/src/mongo/db/catalog/collection_writer_test.cpp @@ -58,8 +58,7 @@ protected: std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(kNss); CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& catalog) { - catalog.registerCollection( - operationContext(), CollectionUUID::gen(), std::move(collection)); + catalog.registerCollection(operationContext(), UUID::gen(), std::move(collection)); }); } @@ -269,7 +268,7 @@ public: CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& catalog) { for (size_t i = 0; i < NumCollections; ++i) { catalog.registerCollection(operationContext(), - CollectionUUID::gen(), + UUID::gen(), std::make_shared<CollectionMock>( NamespaceString("many", fmt::format("coll{}", i)))); } diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp index 390bbbb05df..050859699e8 100644 --- a/src/mongo/db/catalog/create_collection.cpp +++ b/src/mongo/db/catalog/create_collection.cpp @@ -679,7 +679,7 @@ void createChangeStreamPreImagesCollection(OperationContext* opCtx) { Status createCollectionForApplyOps(OperationContext* opCtx, const std::string& dbName, - const OptionalCollectionUUID& ui, + const boost::optional<UUID>& ui, const BSONObj& cmdObj, const bool allowRenameOutOfTheWay, boost::optional<BSONObj> idIndex) { diff --git a/src/mongo/db/catalog/create_collection.h b/src/mongo/db/catalog/create_collection.h index 24d41eb3fbd..a03cac1ae47 100644 --- a/src/mongo/db/catalog/create_collection.h +++ b/src/mongo/db/catalog/create_collection.h @@ -71,7 +71,7 @@ void createChangeStreamPreImagesCollection(OperationContext* opCtx); */ Status createCollectionForApplyOps(OperationContext* opCtx, const std::string& dbName, - const OptionalCollectionUUID& ui, + const boost::optional<UUID>& ui, const BSONObj& cmdObj, bool allowRenameOutOfTheWay, boost::optional<BSONObj> idIndex = boost::none); diff --git a/src/mongo/db/catalog/create_collection_test.cpp b/src/mongo/db/catalog/create_collection_test.cpp index 1a12247c55d..a8cdc840d87 100644 --- a/src/mongo/db/catalog/create_collection_test.cpp +++ b/src/mongo/db/catalog/create_collection_test.cpp @@ -133,7 +133,7 @@ CollectionOptions getCollectionOptions(OperationContext* opCtx, const NamespaceS /** * Returns UUID of collection. */ -CollectionUUID getCollectionUuid(OperationContext* opCtx, const NamespaceString& nss) { +UUID getCollectionUuid(OperationContext* opCtx, const NamespaceString& nss) { auto options = getCollectionOptions(opCtx, nss); ASSERT_TRUE(options.uuid); return *(options.uuid); diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index 176e0801700..b1eabea6389 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -690,7 +690,7 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx, "Attempted to create a new collection without a UUID", "namespace"_attr = nss); } else { - optionsWithUUID.uuid.emplace(CollectionUUID::gen()); + optionsWithUUID.uuid.emplace(UUID::gen()); generatedUUID = true; } } diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp index a02e5ac54e3..e65bbc614c5 100644 --- a/src/mongo/db/catalog/drop_indexes.cpp +++ b/src/mongo/db/catalog/drop_indexes.cpp @@ -264,7 +264,7 @@ Status dropIndexByDescriptor(OperationContext* opCtx, */ std::vector<UUID> abortActiveIndexBuilders(OperationContext* opCtx, const NamespaceString& collectionNs, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<std::string>& indexNames) { if (indexNames.empty()) { return {}; diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index 4322718a5d5..d4b909f0cff 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -336,7 +336,7 @@ Status renameCollectionWithinDB(OperationContext* opCtx, Status renameCollectionWithinDBForApplyOps(OperationContext* opCtx, const NamespaceString& source, const NamespaceString& target, - OptionalCollectionUUID uuidToDrop, + const boost::optional<UUID>& uuidToDrop, repl::OpTime renameOpTimeFromApplyOps, const RenameCollectionOptions& options) { invariant(source.db() == target.db()); @@ -883,7 +883,7 @@ Status renameCollection(OperationContext* opCtx, Status renameCollectionForApplyOps(OperationContext* opCtx, const std::string& dbName, - const OptionalCollectionUUID& uuidToRename, + const boost::optional<UUID>& uuidToRename, const BSONObj& cmd, const repl::OpTime& renameOpTime) { @@ -915,7 +915,7 @@ Status renameCollectionForApplyOps(OperationContext* opCtx, options.dropTarget = cmd["dropTarget"].trueValue(); options.stayTemp = cmd["stayTemp"].trueValue(); - OptionalCollectionUUID uuidToDrop; + boost::optional<UUID> uuidToDrop; if (cmd["dropTarget"].type() == BinData) { auto uuid = uassertStatusOK(UUID::parse(cmd["dropTarget"])); uuidToDrop = uuid; diff --git a/src/mongo/db/catalog/rename_collection.h b/src/mongo/db/catalog/rename_collection.h index b6e8b974dfa..4dee5f8731f 100644 --- a/src/mongo/db/catalog/rename_collection.h +++ b/src/mongo/db/catalog/rename_collection.h @@ -74,7 +74,7 @@ Status renameCollection(OperationContext* opCtx, */ Status renameCollectionForApplyOps(OperationContext* opCtx, const std::string& dbName, - const OptionalCollectionUUID& uuidToRename, + const boost::optional<UUID>& uuidToRename, const BSONObj& cmd, const repl::OpTime& renameOpTime); diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp index 63806e3d824..18a550030f9 100644 --- a/src/mongo/db/catalog/rename_collection_test.cpp +++ b/src/mongo/db/catalog/rename_collection_test.cpp @@ -75,27 +75,27 @@ class OpObserverMock : public OpObserverNoop { public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override; void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override; void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override; void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -127,7 +127,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override; @@ -136,14 +136,14 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override; void postRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override; // Operations written to the oplog. These are operations for which // ReplicationCoordinator::isOplogDisabled() returns false. @@ -153,7 +153,7 @@ public: bool onInsertsIsTargetDatabaseExclusivelyLocked = false; bool onRenameCollectionCalled = false; - OptionalCollectionUUID onRenameCollectionDropTarget; + boost::optional<UUID> onRenameCollectionDropTarget; repl::OpTime renameOpTime = {Timestamp(Seconds(100), 1U), 1LL}; repl::OpTime dropOpTime = {Timestamp(Seconds(100), 1U), 1LL}; @@ -169,7 +169,7 @@ private: void OpObserverMock::onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) { _logOp(opCtx, nss, "index"); @@ -178,7 +178,7 @@ void OpObserverMock::onCreateIndex(OperationContext* opCtx, void OpObserverMock::onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) { @@ -188,7 +188,7 @@ void OpObserverMock::onStartIndexBuild(OperationContext* opCtx, void OpObserverMock::onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) { @@ -198,7 +198,7 @@ void OpObserverMock::onCommitIndexBuild(OperationContext* opCtx, void OpObserverMock::onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -256,7 +256,7 @@ void OpObserverMock::onRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { preRenameCollection( @@ -271,7 +271,7 @@ void OpObserverMock::postRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) { OpObserverNoop::postRenameCollection( opCtx, fromCollection, toCollection, uuid, dropTargetUUID, stayTemp); @@ -283,7 +283,7 @@ repl::OpTime OpObserverMock::preRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { _logOp(opCtx, fromCollection, "rename"); @@ -404,7 +404,7 @@ CollectionOptions _makeCollectionOptionsWithUuid() { /** * Creates a collection with UUID and returns the UUID. */ -CollectionUUID _createCollectionWithUUID(OperationContext* opCtx, const NamespaceString& nss) { +UUID _createCollectionWithUUID(OperationContext* opCtx, const NamespaceString& nss) { const auto options = _makeCollectionOptionsWithUuid(); _createCollection(opCtx, nss, options); return options.uuid.get(); @@ -430,7 +430,7 @@ CollectionOptions _getCollectionOptions(OperationContext* opCtx, const Namespace /** * Returns UUID of collection. */ -CollectionUUID _getCollectionUuid(OperationContext* opCtx, const NamespaceString& nss) { +UUID _getCollectionUuid(OperationContext* opCtx, const NamespaceString& nss) { auto options = _getCollectionOptions(opCtx, nss); ASSERT_TRUE(options.uuid); return *(options.uuid); diff --git a/src/mongo/db/catalog/uncommitted_collections.cpp b/src/mongo/db/catalog/uncommitted_collections.cpp index 31ace2c192e..c5de0db4805 100644 --- a/src/mongo/db/catalog/uncommitted_collections.cpp +++ b/src/mongo/db/catalog/uncommitted_collections.cpp @@ -122,7 +122,7 @@ void UncommittedCollections::erase(UUID uuid, NamespaceString nss, UncommittedCo } void UncommittedCollections::rollback(OperationContext* opCtx, - CollectionUUID uuid, + UUID uuid, UncommittedCollectionsMap* map) { std::shared_ptr<Collection> collPtr; CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) { diff --git a/src/mongo/db/catalog/uncommitted_collections.h b/src/mongo/db/catalog/uncommitted_collections.h index cd6c081714a..9081afebfab 100644 --- a/src/mongo/db/catalog/uncommitted_collections.h +++ b/src/mongo/db/catalog/uncommitted_collections.h @@ -103,9 +103,7 @@ public: * entries for the collection identified by `uuid` to UncommittedCollections. This function * assumes `commit` has previously been called for `uuid`. */ - static void rollback(OperationContext* opCtx, - CollectionUUID uuid, - UncommittedCollectionsMap* map); + static void rollback(OperationContext* opCtx, UUID uuid, UncommittedCollectionsMap* map); /** diff --git a/src/mongo/db/catalog_raii.cpp b/src/mongo/db/catalog_raii.cpp index e98d6d4e7f3..555f3b8cbd7 100644 --- a/src/mongo/db/catalog_raii.cpp +++ b/src/mongo/db/catalog_raii.cpp @@ -229,13 +229,13 @@ AutoGetCollectionLockFree::AutoGetCollectionLockFree(OperationContext* opCtx, // When we restore from yield on this CollectionPtr we will update _collection above and use its // new pointer in the CollectionPtr - _collectionPtr = CollectionPtr(opCtx, - _collection.get(), - [this, restoreFromYield = std::move(restoreFromYield)]( - OperationContext* opCtx, CollectionUUID uuid) { - restoreFromYield(_collection, opCtx, uuid); - return _collection.get(); - }); + _collectionPtr = CollectionPtr( + opCtx, + _collection.get(), + [this, restoreFromYield = std::move(restoreFromYield)](OperationContext* opCtx, UUID uuid) { + restoreFromYield(_collection, opCtx, uuid); + return _collection.get(); + }); { // Check that the sharding database version matches our read. @@ -284,18 +284,16 @@ AutoGetCollectionMaybeLockFree::AutoGetCollectionMaybeLockFree( AutoGetCollectionViewMode viewMode, Date_t deadline) { if (opCtx->isLockFreeReadsOp()) { - _autoGetLockFree.emplace(opCtx, - nsOrUUID, - [](std::shared_ptr<const Collection>& collection, - OperationContext* opCtx, - CollectionUUID uuid) { - LOGV2_FATAL( - 5342700, - "This is a nested lock helper and there was an attempt to " - "yield locks, which should be impossible"); - }, - viewMode, - deadline); + _autoGetLockFree.emplace( + opCtx, + nsOrUUID, + [](std::shared_ptr<const Collection>& collection, OperationContext* opCtx, UUID uuid) { + LOGV2_FATAL(5342700, + "This is a nested lock helper and there was an attempt to " + "yield locks, which should be impossible"); + }, + viewMode, + deadline); } else { _autoGet.emplace(opCtx, nsOrUUID, modeColl, viewMode, deadline); } @@ -309,7 +307,7 @@ struct CollectionWriter::SharedImpl { }; CollectionWriter::CollectionWriter(OperationContext* opCtx, - const CollectionUUID& uuid, + const UUID& uuid, CollectionCatalog::LifetimeMode mode) : _collection(&_storedCollection), _opCtx(opCtx), diff --git a/src/mongo/db/catalog_raii.h b/src/mongo/db/catalog_raii.h index 84445f3ae6f..5f5614d5622 100644 --- a/src/mongo/db/catalog_raii.h +++ b/src/mongo/db/catalog_raii.h @@ -229,7 +229,7 @@ public: * Function used to customize restore after yield behavior */ using RestoreFromYieldFn = - std::function<void(std::shared_ptr<const Collection>&, OperationContext*, CollectionUUID)>; + std::function<void(std::shared_ptr<const Collection>&, OperationContext*, UUID)>; /** * Used by AutoGetCollectionForReadLockFree where it provides implementation for restore after @@ -353,7 +353,7 @@ class CollectionWriter final { public: // Gets the collection from the catalog for the provided uuid CollectionWriter(OperationContext* opCtx, - const CollectionUUID& uuid, + const UUID& uuid, CollectionCatalog::LifetimeMode mode = CollectionCatalog::LifetimeMode::kManagedInWriteUnitOfWork); // Gets the collection from the catalog for the provided namespace string diff --git a/src/mongo/db/catalog_raii_test.cpp b/src/mongo/db/catalog_raii_test.cpp index f1b41a22fee..604f590c045 100644 --- a/src/mongo/db/catalog_raii_test.cpp +++ b/src/mongo/db/catalog_raii_test.cpp @@ -226,7 +226,7 @@ TEST_F(CatalogRAIITestFixture, AutoGetCollectionLockFreeGlobalLockDeadline) { AutoGetCollectionLockFree coll( client2.second.get(), nss, - [](std::shared_ptr<const Collection>&, OperationContext*, CollectionUUID) {}, + [](std::shared_ptr<const Collection>&, OperationContext*, UUID) {}, AutoGetCollectionViewMode::kViewsForbidden, Date_t::now() + timeoutMs); }, @@ -240,9 +240,8 @@ TEST_F(CatalogRAIITestFixture, AutoGetCollectionLockFreeCompatibleWithCollection ASSERT(client1.second->lockState()->isCollectionLockedForMode(nss, MODE_X)); AutoGetCollectionLockFree coll( - client2.second.get(), - nss, - [](std::shared_ptr<const Collection>&, OperationContext*, CollectionUUID) {}); + client2.second.get(), nss, [](std::shared_ptr<const Collection>&, OperationContext*, UUID) { + }); ASSERT(client2.second->lockState()->isLocked()); } @@ -251,9 +250,8 @@ TEST_F(CatalogRAIITestFixture, AutoGetCollectionLockFreeCompatibleWithDatabaseEx ASSERT(client1.second->lockState()->isDbLockedForMode(nss.db(), MODE_X)); AutoGetCollectionLockFree coll( - client2.second.get(), - nss, - [](std::shared_ptr<const Collection>&, OperationContext*, CollectionUUID) {}); + client2.second.get(), nss, [](std::shared_ptr<const Collection>&, OperationContext*, UUID) { + }); ASSERT(client2.second->lockState()->isLocked()); } @@ -263,9 +261,8 @@ TEST_F(CatalogRAIITestFixture, AutoGetCollectionLockFreeCompatibleWithRSTLExclus ASSERT(client1.second->lockState()->isRSTLExclusive()); AutoGetCollectionLockFree coll( - client2.second.get(), - nss, - [](std::shared_ptr<const Collection>&, OperationContext*, CollectionUUID) {}); + client2.second.get(), nss, [](std::shared_ptr<const Collection>&, OperationContext*, UUID) { + }); ASSERT(client2.second->lockState()->isLocked()); } diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index 7798cd2d2a6..5fb4661095e 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -356,7 +356,7 @@ void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx, { CollectionOptions options; - options.uuid = CollectionUUID::gen(); + options.uuid = UUID::gen(); uassertStatusOK(storageInterface->createCollection(opCtx, nss, options)); } diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp index 0402be078e2..d5b84f9483a 100644 --- a/src/mongo/db/commands/mr_test.cpp +++ b/src/mongo/db/commands/mr_test.cpp @@ -241,7 +241,7 @@ public: */ void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override; @@ -251,7 +251,7 @@ public: */ void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override; @@ -299,7 +299,7 @@ public: void MapReduceOpObserver::onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) { indexesCreated.push_back(indexDoc.getOwned()); @@ -307,7 +307,7 @@ void MapReduceOpObserver::onCreateIndex(OperationContext* opCtx, void MapReduceOpObserver::onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) { diff --git a/src/mongo/db/commands_test.cpp b/src/mongo/db/commands_test.cpp index 8fecc92a2ff..60f775c4eff 100644 --- a/src/mongo/db/commands_test.cpp +++ b/src/mongo/db/commands_test.cpp @@ -159,7 +159,7 @@ TEST_F(ParseNsOrUUID, ParseValidColl) { } TEST_F(ParseNsOrUUID, ParseValidUUID) { - const CollectionUUID uuid = UUID::gen(); + const UUID uuid = UUID::gen(); auto cmd = BSON("query" << uuid); auto parsedNsOrUUID = CommandHelpers::parseNsOrUUID("test", cmd); ASSERT_EQUALS(uuid, *parsedNsOrUUID.uuid()); diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp index 1cda869dc71..86099c1b145 100644 --- a/src/mongo/db/db_raii.cpp +++ b/src/mongo/db/db_raii.cpp @@ -196,7 +196,7 @@ auto acquireCollectionAndConsistentSnapshot( */ Status checkSecondaryCollection(OperationContext* opCtx, boost::optional<NamespaceString> nss, - boost::optional<CollectionUUID> uuid, + const boost::optional<UUID>& uuid, const std::shared_ptr<const Collection>& collection, boost::optional<Timestamp> readTimestamp) { invariant(nss || uuid); @@ -492,9 +492,7 @@ void AutoGetCollectionForReadLockFree::EmplaceHelper::emplace( _nsOrUUID, /* restoreFromYield */ [& catalogStasher = _catalogStasher, isSubOperation = _isLockFreeReadSubOperation]( - std::shared_ptr<const Collection>& collection, - OperationContext* opCtx, - CollectionUUID uuid) { + std::shared_ptr<const Collection>& collection, OperationContext* opCtx, UUID uuid) { // A sub-operation should never yield because it would break the consistent in-memory // and on-disk view of the higher level operation. invariant(!isSubOperation); @@ -695,7 +693,7 @@ AutoGetCollectionMultiForReadCommandLockFree::AutoGetCollectionMultiForReadComma _autoCollForReadCommandLockFree._getCollectionPtrForModify().detachRestoreFn(); _autoCollForReadCommandLockFree._getCollectionPtrForModify().attachRestoreFn( - [&](OperationContext* opCtx, CollectionUUID collUUID) { + [&](OperationContext* opCtx, UUID collUUID) { const Collection* primaryCollection = _primaryCollectionRestoreFn(opCtx, collUUID); _secondaryCollectionsRestoreFn(opCtx); return primaryCollection; diff --git a/src/mongo/db/db_raii.h b/src/mongo/db/db_raii.h index 30f8d235fb1..47717a3d236 100644 --- a/src/mongo/db/db_raii.h +++ b/src/mongo/db/db_raii.h @@ -467,10 +467,10 @@ private: // Save a reference to the 'primary' CollectionPtr's original restore lambda so that the new one // can reference it. - std::function<const Collection*(OperationContext*, CollectionUUID)> _primaryCollectionRestoreFn; + std::function<const Collection*(OperationContext*, UUID)> _primaryCollectionRestoreFn; // Used on query yield restore to identify the 'secondary' collections to check. - std::vector<CollectionUUID> _secondaryCollectionUUIDs; + std::vector<UUID> _secondaryCollectionUUIDs; }; /** diff --git a/src/mongo/db/exec/sbe/parser/parser.cpp b/src/mongo/db/exec/sbe/parser/parser.cpp index 1f0bb90d357..a169d712ff8 100644 --- a/src/mongo/db/exec/sbe/parser/parser.cpp +++ b/src/mongo/db/exec/sbe/parser/parser.cpp @@ -1885,7 +1885,7 @@ std::unique_ptr<PlanStage> Parser::parse(OperationContext* opCtx, return std::move(ast->stage); } -CollectionUUID Parser::getCollectionUuid(const std::string& collName) { +UUID Parser::getCollectionUuid(const std::string& collName) { if (!_opCtx) { // The SBE plan cannot actually run without a valid UUID, but it's useful to allow the // parser to run in isolation for unit testing. diff --git a/src/mongo/db/exec/sbe/parser/parser.h b/src/mongo/db/exec/sbe/parser/parser.h index 0979fbd554b..0da73f8fe24 100644 --- a/src/mongo/db/exec/sbe/parser/parser.h +++ b/src/mongo/db/exec/sbe/parser/parser.h @@ -239,7 +239,7 @@ private: value::SlotVector correlated, value::SlotId outputSlot); - CollectionUUID getCollectionUuid(const std::string& collName); + UUID getCollectionUuid(const std::string& collName); PlanNodeId getCurrentPlanNodeId(); }; diff --git a/src/mongo/db/exec/sbe/sbe_plan_size_test.cpp b/src/mongo/db/exec/sbe/sbe_plan_size_test.cpp index aa6ad8545ee..91d97e3e498 100644 --- a/src/mongo/db/exec/sbe/sbe_plan_size_test.cpp +++ b/src/mongo/db/exec/sbe/sbe_plan_size_test.cpp @@ -160,7 +160,7 @@ TEST_F(PlanSizeTest, HashJoin) { } TEST_F(PlanSizeTest, IndexScan) { - auto collUuid = CollectionUUID::parse("00000000-0000-0000-0000-000000000000").getValue(); + auto collUuid = UUID::parse("00000000-0000-0000-0000-000000000000").getValue(); auto stage = makeS<IndexScanStage>(collUuid, StringData(), true, @@ -221,7 +221,7 @@ TEST_F(PlanSizeTest, Project) { } TEST_F(PlanSizeTest, Scan) { - auto collUuid = CollectionUUID::parse("00000000-0000-0000-0000-000000000000").getValue(); + auto collUuid = UUID::parse("00000000-0000-0000-0000-000000000000").getValue(); auto stage = makeS<ScanStage>(collUuid, generateSlotId(), generateSlotId(), diff --git a/src/mongo/db/exec/sbe/sbe_trial_run_tracker_test.cpp b/src/mongo/db/exec/sbe/sbe_trial_run_tracker_test.cpp index 6fb18efb84f..1e0644c35ff 100644 --- a/src/mongo/db/exec/sbe/sbe_trial_run_tracker_test.cpp +++ b/src/mongo/db/exec/sbe/sbe_trial_run_tracker_test.cpp @@ -46,7 +46,7 @@ namespace mongo::sbe { using TrialRunTrackerTest = PlanStageTestFixture; TEST_F(TrialRunTrackerTest, TrackerAttachesToStreamingStage) { - auto collUuid = CollectionUUID::parse("00000000-0000-0000-0000-000000000000").getValue(); + auto collUuid = UUID::parse("00000000-0000-0000-0000-000000000000").getValue(); auto scanStage = makeS<ScanStage>(collUuid, generateSlotId(), generateSlotId(), @@ -90,7 +90,7 @@ TEST_F(TrialRunTrackerTest, TrackerAttachesToBlockingStage) { } TEST_F(TrialRunTrackerTest, TrackerAttachesToBothBlockingAndStreamingStages) { - auto collUuid = CollectionUUID::parse("00000000-0000-0000-0000-000000000000").getValue(); + auto collUuid = UUID::parse("00000000-0000-0000-0000-000000000000").getValue(); auto scanStage = makeS<ScanStage>(collUuid, generateSlotId(), generateSlotId(), diff --git a/src/mongo/db/exec/sbe/stages/collection_helpers.cpp b/src/mongo/db/exec/sbe/stages/collection_helpers.cpp index 01139f3c5c5..6eec51407dd 100644 --- a/src/mongo/db/exec/sbe/stages/collection_helpers.cpp +++ b/src/mongo/db/exec/sbe/stages/collection_helpers.cpp @@ -36,7 +36,7 @@ namespace mongo::sbe { std::tuple<CollectionPtr, NamespaceString, uint64_t> acquireCollection(OperationContext* opCtx, - CollectionUUID collUuid) { + const UUID& collUuid) { // The collection is either locked at a higher level or a snapshot of the catalog (consistent // with the storage engine snapshot from which we are reading) has been stashed on the // 'OperationContext'. Either way, this means that the UUID must still exist in our view of the @@ -50,7 +50,7 @@ std::tuple<CollectionPtr, NamespaceString, uint64_t> acquireCollection(Operation CollectionPtr restoreCollection(OperationContext* opCtx, const NamespaceString& collName, - CollectionUUID collUuid, + const UUID& collUuid, uint64_t catalogEpoch) { // Re-lookup the collection pointer, by UUID. If the collection has been dropped, then this UUID // lookup will result in a null pointer. If the collection has been renamed, then the resulting diff --git a/src/mongo/db/exec/sbe/stages/collection_helpers.h b/src/mongo/db/exec/sbe/stages/collection_helpers.h index ed446c8aaee..4116f2980ff 100644 --- a/src/mongo/db/exec/sbe/stages/collection_helpers.h +++ b/src/mongo/db/exec/sbe/stages/collection_helpers.h @@ -63,7 +63,7 @@ using IndexKeyCorruptionCheckCallback = * the catalog. */ std::tuple<CollectionPtr, NamespaceString, uint64_t> acquireCollection(OperationContext* opCtx, - CollectionUUID collUuid); + const UUID& collUuid); /** * Re-acquires a pointer to the collection, intended for use during SBE yield recovery or when a @@ -74,6 +74,6 @@ std::tuple<CollectionPtr, NamespaceString, uint64_t> acquireCollection(Operation */ CollectionPtr restoreCollection(OperationContext* opCtx, const NamespaceString& collName, - CollectionUUID collUuid, + const UUID& collUuid, uint64_t catalogEpoch); } // namespace mongo::sbe diff --git a/src/mongo/db/exec/sbe/stages/ix_scan.cpp b/src/mongo/db/exec/sbe/stages/ix_scan.cpp index 85bb2be49a8..dc8244b047b 100644 --- a/src/mongo/db/exec/sbe/stages/ix_scan.cpp +++ b/src/mongo/db/exec/sbe/stages/ix_scan.cpp @@ -39,7 +39,7 @@ #include "mongo/db/index/index_access_method.h" namespace mongo::sbe { -IndexScanStage::IndexScanStage(CollectionUUID collUuid, +IndexScanStage::IndexScanStage(UUID collUuid, StringData indexName, bool forward, boost::optional<value::SlotId> recordSlot, diff --git a/src/mongo/db/exec/sbe/stages/ix_scan.h b/src/mongo/db/exec/sbe/stages/ix_scan.h index a215509bb2d..085cc04e81e 100644 --- a/src/mongo/db/exec/sbe/stages/ix_scan.h +++ b/src/mongo/db/exec/sbe/stages/ix_scan.h @@ -72,7 +72,7 @@ namespace mongo::sbe { */ class IndexScanStage final : public PlanStage { public: - IndexScanStage(CollectionUUID collUuid, + IndexScanStage(UUID collUuid, StringData indexName, bool forward, boost::optional<value::SlotId> recordSlot, @@ -118,7 +118,7 @@ private: const KeyString::Value& getSeekKeyLow() const; const KeyString::Value* getSeekKeyHigh() const; - const CollectionUUID _collUuid; + const UUID _collUuid; const std::string _indexName; const bool _forward; const boost::optional<value::SlotId> _recordSlot; diff --git a/src/mongo/db/exec/sbe/stages/scan.cpp b/src/mongo/db/exec/sbe/stages/scan.cpp index 020618c45ce..6be957e2185 100644 --- a/src/mongo/db/exec/sbe/stages/scan.cpp +++ b/src/mongo/db/exec/sbe/stages/scan.cpp @@ -41,7 +41,7 @@ namespace mongo { namespace sbe { -ScanStage::ScanStage(CollectionUUID collectionUuid, +ScanStage::ScanStage(UUID collectionUuid, boost::optional<value::SlotId> recordSlot, boost::optional<value::SlotId> recordIdSlot, boost::optional<value::SlotId> snapshotIdSlot, @@ -559,7 +559,7 @@ size_t ScanStage::estimateCompileTimeSize() const { return size; } -ParallelScanStage::ParallelScanStage(CollectionUUID collectionUuid, +ParallelScanStage::ParallelScanStage(UUID collectionUuid, boost::optional<value::SlotId> recordSlot, boost::optional<value::SlotId> recordIdSlot, boost::optional<value::SlotId> snapshotIdSlot, @@ -588,7 +588,7 @@ ParallelScanStage::ParallelScanStage(CollectionUUID collectionUuid, } ParallelScanStage::ParallelScanStage(const std::shared_ptr<ParallelState>& state, - CollectionUUID collectionUuid, + const UUID& collectionUuid, boost::optional<value::SlotId> recordSlot, boost::optional<value::SlotId> recordIdSlot, boost::optional<value::SlotId> snapshotIdSlot, diff --git a/src/mongo/db/exec/sbe/stages/scan.h b/src/mongo/db/exec/sbe/stages/scan.h index 0fca27f742d..c7f10b35acd 100644 --- a/src/mongo/db/exec/sbe/stages/scan.h +++ b/src/mongo/db/exec/sbe/stages/scan.h @@ -93,7 +93,7 @@ struct ScanCallbacks { */ class ScanStage final : public PlanStage { public: - ScanStage(CollectionUUID collectionUuid, + ScanStage(UUID collectionUuid, boost::optional<value::SlotId> recordSlot, boost::optional<value::SlotId> recordIdSlot, boost::optional<value::SlotId> snapshotIdSlot, @@ -132,7 +132,7 @@ protected: TrialRunTracker* tracker, TrialRunTrackerAttachResultMask childrenAttachResult) override; private: - const CollectionUUID _collUuid; + const UUID _collUuid; const boost::optional<value::SlotId> _recordSlot; const boost::optional<value::SlotId> _recordIdSlot; const boost::optional<value::SlotId> _snapshotIdSlot; @@ -203,7 +203,7 @@ class ParallelScanStage final : public PlanStage { }; public: - ParallelScanStage(CollectionUUID collectionUuid, + ParallelScanStage(UUID collectionUuid, boost::optional<value::SlotId> recordSlot, boost::optional<value::SlotId> recordIdSlot, boost::optional<value::SlotId> snapshotIdSlot, @@ -217,7 +217,7 @@ public: ScanCallbacks callbacks); ParallelScanStage(const std::shared_ptr<ParallelState>& state, - CollectionUUID collectionUuid, + const UUID& collectionUuid, boost::optional<value::SlotId> recordSlot, boost::optional<value::SlotId> recordIdSlot, boost::optional<value::SlotId> snapshotIdSlot, @@ -258,7 +258,7 @@ private: _currentRange = std::numeric_limits<std::size_t>::max(); } - const CollectionUUID _collUuid; + const UUID _collUuid; const boost::optional<value::SlotId> _recordSlot; const boost::optional<value::SlotId> _recordIdSlot; const boost::optional<value::SlotId> _snapshotIdSlot; diff --git a/src/mongo/db/fcv_op_observer.h b/src/mongo/db/fcv_op_observer.h index 68b77fcf49e..8f4bd2a5835 100644 --- a/src/mongo/db/fcv_op_observer.h +++ b/src/mongo/db/fcv_op_observer.h @@ -69,13 +69,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} @@ -86,14 +86,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -105,7 +105,7 @@ public: const BSONObj& doc) final {} void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -143,7 +143,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final {} void onImportCollection(OperationContext* opCtx, @@ -159,7 +159,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final { return {}; @@ -168,7 +168,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final {} void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/free_mon/free_mon_op_observer.h b/src/mongo/db/free_mon/free_mon_op_observer.h index 01a9d14c772..348633c863b 100644 --- a/src/mongo/db/free_mon/free_mon_op_observer.h +++ b/src/mongo/db/free_mon/free_mon_op_observer.h @@ -47,13 +47,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} @@ -64,14 +64,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -99,7 +99,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -141,7 +141,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final {} @@ -159,7 +159,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final { return repl::OpTime(); @@ -168,7 +168,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final {} void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index 8b5e6287ecd..c27a9d26d58 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -641,7 +641,7 @@ Status IndexBuildsCoordinator::_startIndexBuildForRecovery(OperationContext* opC Status IndexBuildsCoordinator::_setUpResumeIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo) { @@ -1688,7 +1688,7 @@ void IndexBuildsCoordinator::updateCurOpOpDescription(OperationContext* opCtx, Status IndexBuildsCoordinator::_setUpIndexBuildForTwoPhaseRecovery( OperationContext* opCtx, StringData dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID) { NamespaceStringOrUUID nssOrUuid{dbName.toString(), collectionUUID}; @@ -1707,7 +1707,7 @@ Status IndexBuildsCoordinator::_setUpIndexBuildForTwoPhaseRecovery( StatusWith<boost::optional<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>>> IndexBuildsCoordinator::_filterSpecsAndRegisterBuild(OperationContext* opCtx, StringData dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol) { diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h index 7bbb0d1f84f..eb62769ab6b 100644 --- a/src/mongo/db/index_builds_coordinator.h +++ b/src/mongo/db/index_builds_coordinator.h @@ -138,7 +138,7 @@ public: virtual StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> startIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, @@ -158,7 +158,7 @@ public: virtual StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> resumeIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo) = 0; @@ -536,7 +536,7 @@ protected: StatusWith<boost::optional<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>>> _filterSpecsAndRegisterBuild(OperationContext* opCtx, StringData dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol); @@ -569,7 +569,7 @@ protected: */ Status _setUpIndexBuildForTwoPhaseRecovery(OperationContext* opCtx, StringData dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID); /** @@ -578,7 +578,7 @@ protected: */ Status _setUpResumeIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo); diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp index 2b5dc0e9aae..1d41a6ac8b3 100644 --- a/src/mongo/db/index_builds_coordinator_mongod.cpp +++ b/src/mongo/db/index_builds_coordinator_mongod.cpp @@ -123,7 +123,7 @@ void IndexBuildsCoordinatorMongod::shutdown(OperationContext* opCtx) { StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, @@ -135,7 +135,7 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx, StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> IndexBuildsCoordinatorMongod::resumeIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo) { @@ -154,7 +154,7 @@ IndexBuildsCoordinatorMongod::resumeIndexBuild(OperationContext* opCtx, StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> IndexBuildsCoordinatorMongod::_startIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, diff --git a/src/mongo/db/index_builds_coordinator_mongod.h b/src/mongo/db/index_builds_coordinator_mongod.h index cce907158fc..d7f6662fcb1 100644 --- a/src/mongo/db/index_builds_coordinator_mongod.h +++ b/src/mongo/db/index_builds_coordinator_mongod.h @@ -72,7 +72,7 @@ public: StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> startIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, @@ -86,7 +86,7 @@ public: StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> resumeIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo) override; @@ -170,7 +170,7 @@ private: StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> _startIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, diff --git a/src/mongo/db/index_builds_coordinator_mongod_test.cpp b/src/mongo/db/index_builds_coordinator_mongod_test.cpp index 3f920324329..a4904b2345f 100644 --- a/src/mongo/db/index_builds_coordinator_mongod_test.cpp +++ b/src/mongo/db/index_builds_coordinator_mongod_test.cpp @@ -54,13 +54,13 @@ public: /** * Creates a collection with a default CollectionsOptions and the given UUID. */ - void createCollection(const NamespaceString& nss, CollectionUUID uuid); + void createCollection(const NamespaceString& nss, UUID uuid); - const CollectionUUID _testFooUUID = UUID::gen(); + const UUID _testFooUUID = UUID::gen(); const NamespaceString _testFooNss = NamespaceString("test.foo"); - const CollectionUUID _testBarUUID = UUID::gen(); + const UUID _testBarUUID = UUID::gen(); const NamespaceString _testBarNss = NamespaceString("test.bar"); - const CollectionUUID _othertestFooUUID = UUID::gen(); + const UUID _othertestFooUUID = UUID::gen(); const NamespaceString _othertestFooNss = NamespaceString("othertest.foo"); const IndexBuildsCoordinator::IndexBuildOptions _indexBuildOptions = { CommitQuorumOptions(CommitQuorumOptions::kDisabled)}; @@ -87,8 +87,7 @@ void IndexBuildsCoordinatorMongodTest::tearDown() { CatalogTestFixture::tearDown(); } -void IndexBuildsCoordinatorMongodTest::createCollection(const NamespaceString& nss, - CollectionUUID uuid) { +void IndexBuildsCoordinatorMongodTest::createCollection(const NamespaceString& nss, UUID uuid) { CollectionOptions options; options.uuid = uuid; ASSERT_OK(storageInterface()->createCollection(operationContext(), nss, options)); diff --git a/src/mongo/db/op_observer.h b/src/mongo/db/op_observer.h index 67c537a5e50..9c2a30501d6 100644 --- a/src/mongo/db/op_observer.h +++ b/src/mongo/db/op_observer.h @@ -66,13 +66,13 @@ struct OplogUpdateEntryArgs { CollectionUpdateArgs* updateArgs; NamespaceString nss; - CollectionUUID uuid; + UUID uuid; // Specifies the pre-image recording option for retryable "findAndModify" commands. RetryableFindAndModifyLocation retryableFindAndModifyLocation = RetryableFindAndModifyLocation::kNone; - OplogUpdateEntryArgs(CollectionUpdateArgs* updateArgs, NamespaceString nss, CollectionUUID uuid) + OplogUpdateEntryArgs(CollectionUpdateArgs* updateArgs, NamespaceString nss, UUID uuid) : updateArgs(updateArgs), nss(std::move(nss)), uuid(std::move(uuid)) {} }; @@ -126,13 +126,13 @@ public: virtual void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) = 0; virtual void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) = 0; @@ -149,14 +149,14 @@ public: virtual void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) = 0; virtual void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -197,7 +197,7 @@ public: */ virtual void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, boost::optional<BSONObj> o2MsgObj, boost::optional<repl::OpTime> preImageOpTime, @@ -314,14 +314,14 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) = 0; virtual repl::OpTime preRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) { @@ -338,7 +338,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) = 0; /** * This function logs an oplog entry when a 'renameCollection' command on a collection is @@ -349,14 +349,14 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) = 0; virtual void onRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) { diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index 0379faec956..e229057d38f 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -254,7 +254,7 @@ OpTimeBundle replLogUpdate(OperationContext* opCtx, OpTimeBundle replLogDelete(OperationContext* opCtx, const NamespaceString& nss, MutableOplogEntry* oplogEntry, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, StmtId stmtId, bool fromMigrate, const boost::optional<BSONObj>& deletedDoc) { @@ -380,7 +380,7 @@ OpObserverImpl::DocumentKey OpObserverImpl::getDocumentKey(OperationContext* opC void OpObserverImpl::onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) { auto txnParticipant = TransactionParticipant::get(opCtx); @@ -407,7 +407,7 @@ void OpObserverImpl::onCreateIndex(OperationContext* opCtx, void OpObserverImpl::onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) { @@ -470,7 +470,7 @@ void OpObserverImpl::onAbortIndexBuildSinglePhase(OperationContext* opCtx, void OpObserverImpl::onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) { @@ -496,7 +496,7 @@ void OpObserverImpl::onCommitIndexBuild(OperationContext* opCtx, void OpObserverImpl::onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -945,7 +945,7 @@ void OpObserverImpl::onDelete(OperationContext* opCtx, void OpObserverImpl::onInternalOpMessage( OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -1141,7 +1141,7 @@ repl::OpTime OpObserverImpl::preRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { return preRenameCollection(opCtx, @@ -1158,7 +1158,7 @@ repl::OpTime OpObserverImpl::preRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) { @@ -1187,7 +1187,7 @@ void OpObserverImpl::postRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) { if (fromCollection.isSystemDotViews()) DurableViewCatalog::onExternalChange(opCtx, fromCollection); @@ -1199,7 +1199,7 @@ void OpObserverImpl::onRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { onRenameCollection(opCtx, @@ -1216,7 +1216,7 @@ void OpObserverImpl::onRenameCollection(OperationContext* const opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) { diff --git a/src/mongo/db/op_observer_impl.h b/src/mongo/db/op_observer_impl.h index 34662b25e22..01785f1367f 100644 --- a/src/mongo/db/op_observer_impl.h +++ b/src/mongo/db/op_observer_impl.h @@ -67,13 +67,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final; void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final; @@ -82,14 +82,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final; void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -113,7 +113,7 @@ public: const OplogDeleteEntryArgs& args) final; void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, boost::optional<BSONObj> o2MsgObj, boost::optional<repl::OpTime> preImageOpTime, @@ -153,14 +153,14 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final; repl::OpTime preRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) final; @@ -168,20 +168,20 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final; void onRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final; void onRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) final; diff --git a/src/mongo/db/op_observer_impl_test.cpp b/src/mongo/db/op_observer_impl_test.cpp index fbfd560f674..5e6f0231db5 100644 --- a/src/mongo/db/op_observer_impl_test.cpp +++ b/src/mongo/db/op_observer_impl_test.cpp @@ -311,7 +311,7 @@ private: TEST_F(OpObserverTest, StartIndexBuildExpectedOplogEntry) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); NamespaceString nss("test.coll"); UUID indexBuildUUID = UUID::gen(); @@ -351,7 +351,7 @@ TEST_F(OpObserverTest, StartIndexBuildExpectedOplogEntry) { TEST_F(OpObserverTest, CommitIndexBuildExpectedOplogEntry) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); NamespaceString nss("test.coll"); UUID indexBuildUUID = UUID::gen(); @@ -391,7 +391,7 @@ TEST_F(OpObserverTest, CommitIndexBuildExpectedOplogEntry) { TEST_F(OpObserverTest, AbortIndexBuildExpectedOplogEntry) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); NamespaceString nss("test.coll"); UUID indexBuildUUID = UUID::gen(); @@ -440,7 +440,7 @@ TEST_F(OpObserverTest, AbortIndexBuildExpectedOplogEntry) { TEST_F(OpObserverTest, CollModWithCollectionOptionsAndTTLInfo) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); // Create 'collMod' command. NamespaceString nss("test.coll"); @@ -499,7 +499,7 @@ TEST_F(OpObserverTest, CollModWithCollectionOptionsAndTTLInfo) { TEST_F(OpObserverTest, CollModWithOnlyCollectionOptions) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); // Create 'collMod' command. NamespaceString nss("test.coll"); @@ -541,7 +541,7 @@ TEST_F(OpObserverTest, CollModWithOnlyCollectionOptions) { TEST_F(OpObserverTest, OnDropCollectionReturnsDropOpTime) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); // Create 'drop' command. NamespaceString nss("test.coll"); @@ -573,8 +573,8 @@ TEST_F(OpObserverTest, OnRenameCollectionReturnsRenameOpTime) { OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); - auto dropTargetUuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); + auto dropTargetUuid = UUID::gen(); auto stayTemp = false; NamespaceString sourceNss("test.foo"); NamespaceString targetNss("test.bar"); @@ -608,7 +608,7 @@ TEST_F(OpObserverTest, OnRenameCollectionOmitsDropTargetFieldIfDropTargetUuidIsN OpObserverImpl opObserver; auto opCtx = cc().makeOperationContext(); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); auto stayTemp = true; NamespaceString sourceNss("test.foo"); NamespaceString targetNss("test.bar"); @@ -962,8 +962,8 @@ protected: TEST_F(OpObserverTransactionTest, TransactionalPrepareTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -1042,7 +1042,7 @@ TEST_F(OpObserverTransactionTest, TransactionalPrepareTest) { TEST_F(OpObserverTransactionTest, TransactionalPreparedCommitTest) { const NamespaceString nss("testDB", "testColl"); - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); const auto doc = BSON("_id" << 0 << "data" << "x"); @@ -1111,7 +1111,7 @@ TEST_F(OpObserverTransactionTest, TransactionalPreparedCommitTest) { TEST_F(OpObserverTransactionTest, TransactionalPreparedAbortTest) { const NamespaceString nss("testDB", "testColl"); - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); const auto doc = BSON("_id" << 0 << "data" << "x"); @@ -1174,7 +1174,7 @@ TEST_F(OpObserverTransactionTest, TransactionalPreparedAbortTest) { TEST_F(OpObserverTransactionTest, TransactionalUnpreparedAbortTest) { const NamespaceString nss("testDB", "testColl"); - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -1299,7 +1299,7 @@ TEST_F(OpObserverTransactionTest, AbortingPreparedTransactionWritesToTransaction TEST_F(OpObserverTransactionTest, CommittingUnpreparedNonEmptyTransactionWritesToTransactionTable) { const NamespaceString nss("testDB", "testColl"); - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "prepareTransaction"); @@ -1376,8 +1376,8 @@ TEST_F(OpObserverTransactionTest, CommittingPreparedTransactionWritesToTransacti TEST_F(OpObserverTransactionTest, TransactionalInsertTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -1435,8 +1435,8 @@ TEST_F(OpObserverTransactionTest, TransactionalInsertTest) { TEST_F(OpObserverTransactionTest, TransactionalUpdateTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "update"); @@ -1489,8 +1489,8 @@ TEST_F(OpObserverTransactionTest, TransactionalUpdateTest) { TEST_F(OpObserverTransactionTest, TransactionalDeleteTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "delete"); @@ -1546,7 +1546,7 @@ private: TEST_F(OpObserverMultiEntryTransactionTest, TransactionSingleStatementTest) { const NamespaceString nss("testDB", "testColl"); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); std::vector<InsertStatement> inserts; @@ -1584,7 +1584,7 @@ public: protected: void testRetryableFindAndModifyUpdateRequestingPostImageHasNeedsRetryImage() { NamespaceString nss = {"test", "coll"}; - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); CollectionUpdateArgs updateArgs; updateArgs.stmtIds = {0}; @@ -1614,7 +1614,7 @@ protected: void testRetryableFindAndModifyUpdateRequestingPreImageHasNeedsRetryImage() { NamespaceString nss = {"test", "coll"}; - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); CollectionUpdateArgs updateArgs; updateArgs.stmtIds = {0}; @@ -1644,7 +1644,7 @@ protected: void testRetryableFindAndModifyDeleteHasNeedsRetryImage() { NamespaceString nss = {"test", "coll"}; - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); WriteUnitOfWork wunit(opCtx()); AutoGetDb autoDb(opCtx(), nss.db(), MODE_X); @@ -2025,7 +2025,7 @@ protected: {kFaMPost, kRecordPreImages, kChangeStreamImagesDisabled, kRecordInSideCollection, 2}}; const NamespaceString _nss{"test", "coll"}; - const CollectionUUID _uuid = CollectionUUID::gen(); + const UUID _uuid = UUID::gen(); }; TEST_F(OnUpdateOutputsTest, TestNonTransactionFundamentalOnUpdateOutputs) { @@ -2136,7 +2136,7 @@ TEST_F(OpObserverTest, TestFundamentalOnInsertsOutputs) { opObserver.addObserver(std::make_unique<OpObserverImpl>()); NamespaceString nss("test", "coll"); - CollectionUUID uuid = CollectionUUID::gen(); + UUID uuid = UUID::gen(); const bool isRetryableWrite = true; const bool isNotRetryableWrite = false; @@ -2360,7 +2360,7 @@ protected: {kRecordPreImages, kChangeStreamImagesDisabled, kRecordInSideCollection, 2}}; const NamespaceString _nss{"test", "coll"}; - const CollectionUUID _uuid = CollectionUUID::gen(); + const UUID _uuid = UUID::gen(); const BSONObj _deletedDoc = BSON("_id" << 0 << "valuePriorToDelete" << "marvelous"); }; @@ -2470,8 +2470,8 @@ TEST_F(OnDeleteOutputsTest, TestTransactionFundamentalOnDeleteOutputs) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionalInsertTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); std::vector<InsertStatement> inserts1; @@ -2534,8 +2534,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionalInsertTest) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionalUpdateTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "update"); @@ -2603,7 +2603,7 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionalUpdateTest) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionPreImageTest) { const NamespaceString nss1("testDB", "testColl"); - auto uuid1 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "txntest"); @@ -2680,7 +2680,7 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionPreImageTest) { TEST_F(OpObserverMultiEntryTransactionTest, PreparedTransactionPreImageTest) { const NamespaceString nss1("testDB", "testColl"); - auto uuid1 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "txntest"); @@ -2765,8 +2765,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, PreparedTransactionPreImageTest) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionalDeleteTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "delete"); @@ -2822,8 +2822,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionalDeleteTest) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionalInsertPrepareTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -2902,8 +2902,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionalInsertPrepareTest) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionalUpdatePrepareTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "update"); @@ -2982,8 +2982,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionalUpdatePrepareTest) { TEST_F(OpObserverMultiEntryTransactionTest, TransactionalDeletePrepareTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "delete"); @@ -3051,7 +3051,7 @@ TEST_F(OpObserverMultiEntryTransactionTest, TransactionalDeletePrepareTest) { TEST_F(OpObserverMultiEntryTransactionTest, CommitPreparedTest) { const NamespaceString nss1("testDB", "testColl"); - auto uuid1 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -3137,7 +3137,7 @@ TEST_F(OpObserverMultiEntryTransactionTest, CommitPreparedTest) { TEST_F(OpObserverMultiEntryTransactionTest, AbortPreparedTest) { const NamespaceString nss1("testDB", "testColl"); - auto uuid1 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -3214,8 +3214,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, UnpreparedTransactionPackingTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); std::vector<InsertStatement> inserts1; @@ -3268,8 +3268,8 @@ TEST_F(OpObserverMultiEntryTransactionTest, PreparedTransactionPackingTest) { const NamespaceString nss1("testDB", "testColl"); const NamespaceString nss2("testDB2", "testColl2"); - auto uuid1 = CollectionUUID::gen(); - auto uuid2 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); + auto uuid2 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); std::vector<InsertStatement> inserts1; @@ -3324,7 +3324,7 @@ TEST_F(OpObserverMultiEntryTransactionTest, PreparedTransactionPackingTest) { TEST_F(OpObserverMultiEntryTransactionTest, CommitPreparedPackingTest) { gMaxNumberOfTransactionOperationsInSingleOplogEntry = std::numeric_limits<int>::max(); const NamespaceString nss1("testDB", "testColl"); - auto uuid1 = CollectionUUID::gen(); + auto uuid1 = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -3422,7 +3422,7 @@ private: // two oplog entry transaction. TEST_F(OpObserverLargeTransactionTest, LargeTransactionCreatesMultipleOplogEntries) { const NamespaceString nss("testDB", "testColl"); - auto uuid = CollectionUUID::gen(); + auto uuid = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); @@ -3513,7 +3513,7 @@ TEST_F(OpObserverTest, OnInsertChecksIfTenantMigrationIsBlockingWrites) { auto opCtx = cc().makeOperationContext(); const std::string kTenantId = "tenantId"; const NamespaceString nss("tenantId_db", "testColl"); - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); // Add a tenant migration access blocker on donor for blocking writes. auto donorMtab = std::make_shared<TenantMigrationDonorAccessBlocker>( @@ -3552,7 +3552,7 @@ TEST_F(OpObserverTransactionTest, TenantMigrationAccessBlockerRegistry::get(getServiceContext()).add(kTenantId, donorMtab); const NamespaceString nss("tenantId_db", "testColl"); - const auto uuid = CollectionUUID::gen(); + const auto uuid = UUID::gen(); auto txnParticipant = TransactionParticipant::get(opCtx()); txnParticipant.unstashTransactionResources(opCtx(), "insert"); diff --git a/src/mongo/db/op_observer_noop.h b/src/mongo/db/op_observer_noop.h index 386abf2de1d..f458d891846 100644 --- a/src/mongo/db/op_observer_noop.h +++ b/src/mongo/db/op_observer_noop.h @@ -37,13 +37,13 @@ class OpObserverNoop : public OpObserver { public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} @@ -56,14 +56,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -87,7 +87,7 @@ public: const OplogDeleteEntryArgs& args) override {} void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -125,7 +125,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override {} void onImportCollection(OperationContext* opCtx, @@ -141,7 +141,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { return {}; @@ -150,7 +150,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override {} void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/op_observer_registry.h b/src/mongo/db/op_observer_registry.h index 584b99f5712..c5f68467066 100644 --- a/src/mongo/db/op_observer_registry.h +++ b/src/mongo/db/op_observer_registry.h @@ -60,7 +60,7 @@ public: void onCreateIndex(OperationContext* const opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override { ReservedTimes times{opCtx}; @@ -70,7 +70,7 @@ public: void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override { @@ -98,7 +98,7 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override { @@ -110,7 +110,7 @@ public: void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -159,7 +159,7 @@ public: void onInternalOpMessage(OperationContext* const opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -245,7 +245,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { onRenameCollection(opCtx, @@ -262,7 +262,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) override { @@ -302,7 +302,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { return preRenameCollection(opCtx, @@ -319,7 +319,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp, bool markFromMigrate) override { @@ -342,7 +342,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override { ReservedTimes times{opCtx}; for (auto& o : _observers) diff --git a/src/mongo/db/op_observer_registry_test.cpp b/src/mongo/db/op_observer_registry_test.cpp index a21cba6b111..39a6f3208f4 100644 --- a/src/mongo/db/op_observer_registry_test.cpp +++ b/src/mongo/db/op_observer_registry_test.cpp @@ -68,7 +68,7 @@ struct TestObserver : public OpObserverNoop { const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { preRenameCollection( @@ -81,7 +81,7 @@ struct TestObserver : public OpObserverNoop { const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { OpObserver::Times::get(opCtx).reservedOpTimes.push_back(opTime); @@ -91,7 +91,7 @@ struct TestObserver : public OpObserverNoop { const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override {} }; diff --git a/src/mongo/db/query/query_request_test.cpp b/src/mongo/db/query/query_request_test.cpp index 88c41a2d821..8c58484990a 100644 --- a/src/mongo/db/query/query_request_test.cpp +++ b/src/mongo/db/query/query_request_test.cpp @@ -1565,7 +1565,7 @@ TEST(QueryRequestHelperTest, ValidateResponseWrongDataType) { class QueryRequestTest : public ServiceContextTest {}; TEST_F(QueryRequestTest, ParseFromUUID) { - const CollectionUUID uuid = UUID::gen(); + const UUID uuid = UUID::gen(); NamespaceStringOrUUID nssOrUUID("test", uuid); diff --git a/src/mongo/db/repl/apply_ops_test.cpp b/src/mongo/db/repl/apply_ops_test.cpp index 26ed9d22aec..5fc6b9b0236 100644 --- a/src/mongo/db/repl/apply_ops_test.cpp +++ b/src/mongo/db/repl/apply_ops_test.cpp @@ -192,7 +192,7 @@ TEST_F(ApplyOpsTest, AtomicApplyOpsWithNoOpsReturnsSuccess) { * Creates an applyOps command object with a single insert operation. */ BSONObj makeApplyOpsWithInsertOperation(const NamespaceString& nss, - const OptionalCollectionUUID& uuid, + const boost::optional<UUID>& uuid, const BSONObj& documentToInsert) { auto insertOp = uuid ? BSON("op" << "i" diff --git a/src/mongo/db/repl/dbcheck.cpp b/src/mongo/db/repl/dbcheck.cpp index 3a2f7d0db1f..f2ebe1c4d3b 100644 --- a/src/mongo/db/repl/dbcheck.cpp +++ b/src/mongo/db/repl/dbcheck.cpp @@ -236,8 +236,7 @@ std::pair<boost::optional<UUID>, boost::optional<UUID>> getPrevAndNextUUIDs( auto catalog = CollectionCatalog::get(opCtx); const UUID uuid = collection->uuid(); - std::vector<CollectionUUID> collectionUUIDs = - catalog->getAllCollectionUUIDsFromDb(collection->ns().db()); + std::vector<UUID> collectionUUIDs = catalog->getAllCollectionUUIDsFromDb(collection->ns().db()); auto uuidIt = std::find(collectionUUIDs.begin(), collectionUUIDs.end(), uuid); invariant(uuidIt != collectionUUIDs.end()); diff --git a/src/mongo/db/repl/idempotency_test_fixture.cpp b/src/mongo/db/repl/idempotency_test_fixture.cpp index 4a0891546f6..938ccb8749e 100644 --- a/src/mongo/db/repl/idempotency_test_fixture.cpp +++ b/src/mongo/db/repl/idempotency_test_fixture.cpp @@ -215,7 +215,7 @@ void IdempotencyTest::testOpsAreIdempotent(std::vector<OplogEntry> ops, Sequence } } -OplogEntry IdempotencyTest::createCollection(CollectionUUID uuid) { +OplogEntry IdempotencyTest::createCollection(UUID uuid) { return makeCreateCollectionOplogEntry(nextOpTime(), nss, BSON("uuid" << uuid)); } @@ -372,7 +372,7 @@ std::vector<CollectionState> IdempotencyTest::validateAllCollections() { } CollectionState IdempotencyTest::validate(const NamespaceString& nss) { - auto collUUID = [&]() -> OptionalCollectionUUID { + auto collUUID = [&]() -> boost::optional<UUID> { AutoGetCollectionForReadCommand autoColl(_opCtx.get(), nss); if (const auto& collection = autoColl.getCollection()) { return collection->uuid(); diff --git a/src/mongo/db/repl/idempotency_test_fixture.h b/src/mongo/db/repl/idempotency_test_fixture.h index 1432e35f1f3..3c79dc60a0e 100644 --- a/src/mongo/db/repl/idempotency_test_fixture.h +++ b/src/mongo/db/repl/idempotency_test_fixture.h @@ -103,7 +103,7 @@ public: protected: enum class SequenceType : int { kEntireSequence, kAnyPrefix, kAnySuffix, kAnyPrefixOrSuffix }; - OplogEntry createCollection(CollectionUUID uuid = UUID::gen()); + OplogEntry createCollection(UUID uuid = UUID::gen()); OplogEntry dropCollection(); OplogEntry insert(const BSONObj& obj); template <class IdType> diff --git a/src/mongo/db/repl/oplog_applier_impl_test.cpp b/src/mongo/db/repl/oplog_applier_impl_test.cpp index 474099cccdc..93ea0fa1a8f 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test.cpp @@ -2394,7 +2394,7 @@ TEST_F(IdempotencyTest, CreateCollectionWithValidation) { TEST_F(IdempotencyTest, CreateCollectionWithCollation) { ASSERT_OK(ReplicationCoordinator::get(getGlobalServiceContext()) ->setFollowerMode(MemberState::RS_RECOVERING)); - CollectionUUID uuid = UUID::gen(); + UUID uuid = UUID::gen(); auto runOpsAndValidate = [this, uuid]() { auto options = BSON("collation" diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp index 82b189b4b7b..d86f87610a0 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp @@ -104,7 +104,7 @@ void OplogApplierImplOpObserver::onRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { if (!onRenameCollectionFn) { @@ -116,7 +116,7 @@ void OplogApplierImplOpObserver::onRenameCollection(OperationContext* opCtx, void OplogApplierImplOpObserver::onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) { if (!onCreateIndexFn) { @@ -240,7 +240,7 @@ void OplogApplierImplTest::_testApplyOplogEntryOrGroupedInsertsCrudOperation( _opObserver->onDeleteFn = [&](OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, StmtId stmtId, const OplogDeleteEntryArgs& args) { applyOpCalled = true; @@ -401,7 +401,7 @@ bool docExists(OperationContext* opCtx, const NamespaceString& nss, const BSONOb */ OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, BSONObj o, boost::optional<BSONObj> o2, boost::optional<bool> fromMigrate) { @@ -426,7 +426,7 @@ OplogEntry makeOplogEntry(OpTypeEnum opType, boost::none)}; // needsRetryImage } -OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, OptionalCollectionUUID uuid) { +OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, boost::optional<UUID> uuid) { return makeOplogEntry(opType, nss, uuid, BSON("_id" << 0), boost::none); } diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.h b/src/mongo/db/repl/oplog_applier_impl_test_fixture.h index a3fb7131ad0..0c8729259b2 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.h +++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.h @@ -112,7 +112,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override; @@ -121,7 +121,7 @@ public: */ void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override; @@ -151,7 +151,7 @@ public: std::function<void(OperationContext*, const NamespaceString&, - OptionalCollectionUUID, + boost::optional<UUID>, StmtId, const OplogDeleteEntryArgs&)> onDeleteFn; @@ -168,18 +168,18 @@ public: std::function<void(OperationContext*, const NamespaceString&, const NamespaceString&, - OptionalCollectionUUID, - OptionalCollectionUUID, + boost::optional<UUID>, + boost::optional<UUID>, std::uint64_t, bool)> onRenameCollectionFn; - std::function<void(OperationContext*, const NamespaceString&, CollectionUUID, BSONObj, bool)> + std::function<void(OperationContext*, const NamespaceString&, UUID, BSONObj, bool)> onCreateIndexFn; std::function<void(OperationContext*, const NamespaceString&, - OptionalCollectionUUID, + boost::optional<UUID>, const std::string&, const BSONObj&)> onDropIndexFn; @@ -266,12 +266,12 @@ bool docExists(OperationContext* opCtx, const NamespaceString& nss, const BSONOb */ OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, BSONObj o, boost::optional<BSONObj> o2 = boost::none, boost::optional<bool> fromMigrate = boost::none); -OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, OptionalCollectionUUID uuid); +OplogEntry makeOplogEntry(OpTypeEnum opType, NamespaceString nss, boost::optional<UUID> uuid); /** * Creates collection options suitable for oplog. diff --git a/src/mongo/db/repl/oplog_entry.cpp b/src/mongo/db/repl/oplog_entry.cpp index ee80f7afaf3..c7e747706be 100644 --- a/src/mongo/db/repl/oplog_entry.cpp +++ b/src/mongo/db/repl/oplog_entry.cpp @@ -231,7 +231,7 @@ ReplOperation MutableOplogEntry::makeCreateCommand(const NamespaceString nss, } ReplOperation MutableOplogEntry::makeCreateIndexesCommand(const NamespaceString nss, - CollectionUUID uuid, + const UUID& uuid, const BSONObj& indexDoc) { ReplOperation op; op.setOpType(OpTypeEnum::kCommand); diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h index ce141a2b987..013ea0bafcb 100644 --- a/src/mongo/db/repl/oplog_entry.h +++ b/src/mongo/db/repl/oplog_entry.h @@ -161,7 +161,7 @@ public: const BSONObj& idIndex); static ReplOperation makeCreateIndexesCommand(NamespaceString nss, - CollectionUUID uuid, + const UUID& uuid, const BSONObj& indexDoc); static BSONObj makeCreateCollCmdObj(const NamespaceString& collectionName, diff --git a/src/mongo/db/repl/primary_only_service_op_observer.h b/src/mongo/db/repl/primary_only_service_op_observer.h index 6d835c893cd..f434e29e34d 100644 --- a/src/mongo/db/repl/primary_only_service_op_observer.h +++ b/src/mongo/db/repl/primary_only_service_op_observer.h @@ -49,13 +49,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} @@ -66,14 +66,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -101,7 +101,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -143,7 +143,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final {} @@ -161,7 +161,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final { return repl::OpTime(); @@ -170,7 +170,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final {} void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp index ce085a300df..365d59a9ea9 100644 --- a/src/mongo/db/repl/rollback_test_fixture.cpp +++ b/src/mongo/db/repl/rollback_test_fixture.cpp @@ -166,7 +166,7 @@ std::pair<BSONObj, RecordId> RollbackTest::makeCRUDOp(OpTypeEnum opType, std::pair<BSONObj, RecordId> RollbackTest::makeCommandOp(Timestamp ts, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, StringData nss, BSONObj cmdObj, int recordId, @@ -188,7 +188,7 @@ std::pair<BSONObj, RecordId> RollbackTest::makeCommandOp(Timestamp ts, return std::make_pair(bob.obj(), RecordId(recordId)); } -std::pair<BSONObj, RecordId> RollbackTest::makeCommandOpForApplyOps(OptionalCollectionUUID uuid, +std::pair<BSONObj, RecordId> RollbackTest::makeCommandOpForApplyOps(boost::optional<UUID> uuid, StringData nss, BSONObj cmdObj, int recordId, diff --git a/src/mongo/db/repl/rollback_test_fixture.h b/src/mongo/db/repl/rollback_test_fixture.h index 7fabb9aa5a3..bae1e9293b4 100644 --- a/src/mongo/db/repl/rollback_test_fixture.h +++ b/src/mongo/db/repl/rollback_test_fixture.h @@ -100,7 +100,7 @@ public: * Creates an oplog entry with a recordId for a command operation. */ static std::pair<BSONObj, RecordId> makeCommandOp(Timestamp ts, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, StringData nss, BSONObj cmdObj, int recordId, @@ -111,7 +111,7 @@ public: * a "ts" or "wall" field. This is used for creating inner ops for applyOps entries. */ static std::pair<BSONObj, RecordId> makeCommandOpForApplyOps( - OptionalCollectionUUID uuid, + boost::optional<UUID> uuid, StringData nss, BSONObj cmdObj, int recordId, diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index ab900376345..9f54c362df3 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -166,12 +166,13 @@ OplogInterfaceMock::Operation makeCreateIndexOplogEntry(const CollectionPtr& col RecordId(time)); } -OplogInterfaceMock::Operation makeRenameCollectionOplogEntry(const NamespaceString& renameFrom, - const NamespaceString& renameTo, - const UUID collectionUUID, - OptionalCollectionUUID dropTarget, - const bool stayTemp, - OpTime opTime) { +OplogInterfaceMock::Operation makeRenameCollectionOplogEntry( + const NamespaceString& renameFrom, + const NamespaceString& renameTo, + const UUID collectionUUID, + const boost::optional<UUID>& dropTarget, + const bool stayTemp, + OpTime opTime) { BSONObjBuilder cmd; cmd.append("renameCollection", renameFrom.ns()); cmd.append("to", renameTo.ns()); diff --git a/src/mongo/db/repl/tenant_collection_cloner_test.cpp b/src/mongo/db/repl/tenant_collection_cloner_test.cpp index 0fd4bd5cd20..6eaf831695f 100644 --- a/src/mongo/db/repl/tenant_collection_cloner_test.cpp +++ b/src/mongo/db/repl/tenant_collection_cloner_test.cpp @@ -81,7 +81,7 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final { if (nss == nssToCapture) { diff --git a/src/mongo/db/repl/tenant_migration_donor_op_observer.h b/src/mongo/db/repl/tenant_migration_donor_op_observer.h index cb7e2feea6e..90e3a49c743 100644 --- a/src/mongo/db/repl/tenant_migration_donor_op_observer.h +++ b/src/mongo/db/repl/tenant_migration_donor_op_observer.h @@ -47,13 +47,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} @@ -64,14 +64,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -99,7 +99,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -140,7 +140,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final {} @@ -158,7 +158,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final { return repl::OpTime(); @@ -167,7 +167,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final {} void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/repl/tenant_migration_recipient_op_observer.h b/src/mongo/db/repl/tenant_migration_recipient_op_observer.h index fa3a2ac1973..fe7178819d6 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_op_observer.h +++ b/src/mongo/db/repl/tenant_migration_recipient_op_observer.h @@ -48,13 +48,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) final {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} @@ -65,14 +65,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) final {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -100,7 +100,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -142,7 +142,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final {} @@ -160,7 +160,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) final { return repl::OpTime(); @@ -169,7 +169,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) final {} void onApplyOps(OperationContext* opCtx, const std::string& dbName, diff --git a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp index e30302d9e49..9b1fb15fd3c 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp @@ -83,7 +83,7 @@ const Timestamp kDefaultStartMigrationTimestamp(1, 1); OplogEntry makeOplogEntry(OpTime opTime, OpTypeEnum opType, NamespaceString nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, BSONObj o, boost::optional<BSONObj> o2) { return {DurableOplogEntry(opTime, // optime @@ -109,7 +109,7 @@ OplogEntry makeOplogEntry(OpTime opTime, MutableOplogEntry makeNoOpOplogEntry(OpTime opTime, NamespaceString nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, BSONObj o, boost::optional<UUID> migrationUUID) { MutableOplogEntry oplogEntry; diff --git a/src/mongo/db/repl/tenant_oplog_applier_test.cpp b/src/mongo/db/repl/tenant_oplog_applier_test.cpp index f8c8fa2d901..e366b797c31 100644 --- a/src/mongo/db/repl/tenant_oplog_applier_test.cpp +++ b/src/mongo/db/repl/tenant_oplog_applier_test.cpp @@ -65,7 +65,7 @@ class TenantOplogApplierTestOpObserver : public OplogApplierImplOpObserver { public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -613,7 +613,7 @@ TEST_F(TenantOplogApplierTest, ApplyDelete_DatabaseMissing) { bool onDeleteCalled = false; _opObserver->onDeleteFn = [&](OperationContext* opCtx, const NamespaceString&, - OptionalCollectionUUID, + boost::optional<UUID>, StmtId, const OplogDeleteEntryArgs&) { onDeleteCalled = true; }; pushOps({entry}); @@ -636,7 +636,7 @@ TEST_F(TenantOplogApplierTest, ApplyDelete_CollectionMissing) { bool onDeleteCalled = false; _opObserver->onDeleteFn = [&](OperationContext* opCtx, const NamespaceString&, - OptionalCollectionUUID, + boost::optional<UUID>, StmtId, const OplogDeleteEntryArgs&) { onDeleteCalled = true; }; pushOps({entry}); @@ -660,7 +660,7 @@ TEST_F(TenantOplogApplierTest, ApplyDelete_DocumentMissing) { bool onDeleteCalled = false; _opObserver->onDeleteFn = [&](OperationContext* opCtx, const NamespaceString&, - OptionalCollectionUUID, + boost::optional<UUID>, StmtId, const OplogDeleteEntryArgs&) { onDeleteCalled = true; }; pushOps({entry}); @@ -685,7 +685,7 @@ TEST_F(TenantOplogApplierTest, ApplyDelete_Success) { bool onDeleteCalled = false; _opObserver->onDeleteFn = [&](OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID observer_uuid, + const boost::optional<UUID>& observer_uuid, StmtId, const OplogDeleteEntryArgs& args) { onDeleteCalled = true; @@ -753,8 +753,8 @@ TEST_F(TenantOplogApplierTest, ApplyRenameCollCommand_CollExisting) { _opObserver->onRenameCollectionFn = [&](OperationContext* opCtx, const NamespaceString& fromColl, const NamespaceString& toColl, - OptionalCollectionUUID uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& uuid, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) { applyCmdCalled = true; }; auto entry = OplogEntry(op); @@ -818,7 +818,7 @@ TEST_F(TenantOplogApplierTest, ApplyCreateIndexesCommand_Success) { bool applyCmdCalled = false; _opObserver->onCreateIndexFn = [&](OperationContext* opCtx, const NamespaceString& collNss, - CollectionUUID collUuid, + const UUID& collUuid, BSONObj indexDoc, bool fromMigrate) { ASSERT_FALSE(applyCmdCalled); @@ -908,7 +908,7 @@ TEST_F(TenantOplogApplierTest, ApplyDropIndexesCommand_IndexNotFound) { bool applyCmdCalled = false; _opObserver->onDropIndexFn = [&](OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const std::string& indexName, const BSONObj& idxDescriptor) { applyCmdCalled = true; }; diff --git a/src/mongo/db/s/config_server_op_observer.h b/src/mongo/db/s/config_server_op_observer.h index 549208fb060..71ba94767a9 100644 --- a/src/mongo/db/s/config_server_op_observer.h +++ b/src/mongo/db/s/config_server_op_observer.h @@ -48,13 +48,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} @@ -67,14 +67,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -102,7 +102,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -144,7 +144,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override {} void onImportCollection(OperationContext* opCtx, @@ -160,7 +160,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { return repl::OpTime(); @@ -169,7 +169,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override {} void onApplyOps(OperationContext* opCtx, diff --git a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp index d807ef7e5ed..5557fd65554 100644 --- a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp +++ b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp @@ -82,7 +82,7 @@ bool collectionHasSimpleCollation(OperationContext* opCtx, const NamespaceString ReshardingCollectionCloner::ReshardingCollectionCloner(std::unique_ptr<Env> env, ShardKeyPattern newShardKeyPattern, NamespaceString sourceNss, - CollectionUUID sourceUUID, + const UUID& sourceUUID, ShardId recipientShard, Timestamp atClusterTime, NamespaceString outputNss) diff --git a/src/mongo/db/s/resharding/resharding_collection_cloner.h b/src/mongo/db/s/resharding/resharding_collection_cloner.h index cf1035ba3a7..3ce9627606f 100644 --- a/src/mongo/db/s/resharding/resharding_collection_cloner.h +++ b/src/mongo/db/s/resharding/resharding_collection_cloner.h @@ -76,7 +76,7 @@ public: ReshardingCollectionCloner(std::unique_ptr<Env> env, ShardKeyPattern newShardKeyPattern, NamespaceString sourceNss, - CollectionUUID sourceUUID, + const UUID& sourceUUID, ShardId recipientShard, Timestamp atClusterTime, NamespaceString outputNss); @@ -114,7 +114,7 @@ private: const std::unique_ptr<Env> _env; const ShardKeyPattern _newShardKeyPattern; const NamespaceString _sourceNss; - const CollectionUUID _sourceUUID; + const UUID _sourceUUID; const ShardId _recipientShard; const Timestamp _atClusterTime; const NamespaceString _outputNss; diff --git a/src/mongo/db/s/resharding/resharding_collection_cloner_test.cpp b/src/mongo/db/s/resharding/resharding_collection_cloner_test.cpp index f52a55fbb8f..5d6c6aba3f2 100644 --- a/src/mongo/db/s/resharding/resharding_collection_cloner_test.cpp +++ b/src/mongo/db/s/resharding/resharding_collection_cloner_test.cpp @@ -123,7 +123,7 @@ protected: private: const NamespaceString _sourceNss = NamespaceString("test"_sd, "collection_being_resharded"_sd); - const CollectionUUID _sourceUUID = UUID::gen(); + const UUID _sourceUUID = UUID::gen(); ServiceContext::UniqueOperationContext _opCtx = makeOperationContext(); std::unique_ptr<ReshardingMetrics> _metrics; diff --git a/src/mongo/db/s/resharding/resharding_data_copy_util.cpp b/src/mongo/db/s/resharding/resharding_data_copy_util.cpp index 9f7b7bf6aff..9e6b143efa6 100644 --- a/src/mongo/db/s/resharding/resharding_data_copy_util.cpp +++ b/src/mongo/db/s/resharding/resharding_data_copy_util.cpp @@ -73,7 +73,7 @@ void ensureCollectionExists(OperationContext* opCtx, void ensureCollectionDropped(OperationContext* opCtx, const NamespaceString& nss, - const boost::optional<CollectionUUID>& uuid) { + const boost::optional<UUID>& uuid) { invariant(!opCtx->lockState()->isLocked()); invariant(!opCtx->lockState()->inAWriteUnitOfWork()); diff --git a/src/mongo/db/s/resharding/resharding_data_copy_util.h b/src/mongo/db/s/resharding/resharding_data_copy_util.h index c34768dcea1..9f2a332ef6c 100644 --- a/src/mongo/db/s/resharding/resharding_data_copy_util.h +++ b/src/mongo/db/s/resharding/resharding_data_copy_util.h @@ -68,7 +68,7 @@ void ensureCollectionExists(OperationContext* opCtx, */ void ensureCollectionDropped(OperationContext* opCtx, const NamespaceString& nss, - const boost::optional<CollectionUUID>& uuid = boost::none); + const boost::optional<UUID>& uuid = boost::none); /** * Removes documents from the oplog applier progress and transaction applier progress collections * that are associated with an in-progress resharding operation. Also drops all oplog buffer diff --git a/src/mongo/db/s/resharding/resharding_data_replication_test.cpp b/src/mongo/db/s/resharding/resharding_data_replication_test.cpp index e6602cb14de..88af9141a95 100644 --- a/src/mongo/db/s/resharding/resharding_data_replication_test.cpp +++ b/src/mongo/db/s/resharding/resharding_data_replication_test.cpp @@ -102,7 +102,7 @@ public: return _sourceNss; } - const CollectionUUID& sourceUUID() { + const UUID& sourceUUID() { return _sourceUUID; } @@ -117,7 +117,7 @@ private: const StringData _currentShardKey = "sk"; const NamespaceString _sourceNss{"test_crud", "collection_being_resharded"}; - const CollectionUUID _sourceUUID = UUID::gen(); + const UUID _sourceUUID = UUID::gen(); const ShardId _myDonorId{"myDonorId"}; }; diff --git a/src/mongo/db/s/resharding/resharding_op_observer.h b/src/mongo/db/s/resharding/resharding_op_observer.h index a03b0233fd8..88101c36b32 100644 --- a/src/mongo/db/s/resharding/resharding_op_observer.h +++ b/src/mongo/db/s/resharding/resharding_op_observer.h @@ -63,13 +63,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} @@ -82,14 +82,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -117,7 +117,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -161,7 +161,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override {} @@ -179,7 +179,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { return repl::OpTime(); @@ -189,7 +189,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override {} void onApplyOps(OperationContext* opCtx, diff --git a/src/mongo/db/s/resharding/resharding_oplog_batch_applier_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_batch_applier_test.cpp index 684f3f4990a..2d203a51eb1 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_batch_applier_test.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_batch_applier_test.cpp @@ -325,7 +325,7 @@ private: const StringData _currentShardKey = "sk"; const NamespaceString _sourceNss{"test_crud", "collection_being_resharded"}; - const CollectionUUID _sourceUUID = UUID::gen(); + const UUID _sourceUUID = UUID::gen(); const ShardId _myDonorId{"myDonorId"}; const ShardId _otherDonorId{"otherDonorId"}; diff --git a/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp index cef0843a76b..cc255508b64 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_crud_application_test.cpp @@ -297,7 +297,7 @@ private: ChunkManager makeChunkManagerForOutputCollection() { const OID epoch = OID::gen(); - const CollectionUUID outputUuid = UUID::gen(); + const UUID outputUuid = UUID::gen(); std::vector<ChunkType> chunks = { ChunkType{outputUuid, ChunkRange{BSON(_newShardKey << MINKEY), BSON(_newShardKey << MAXKEY)}, @@ -319,7 +319,7 @@ private: const StringData _newShardKey = "new_sk"; const NamespaceString _sourceNss{"test_crud", "collection_being_resharded"}; - const CollectionUUID _sourceUUID = UUID::gen(); + const UUID _sourceUUID = UUID::gen(); const ShardId _myDonorId{"myDonorId"}; const ShardId _otherDonorId{"otherDonorId"}; diff --git a/src/mongo/db/s/resharding/resharding_recipient_service_external_state.cpp b/src/mongo/db/s/resharding/resharding_recipient_service_external_state.cpp index 660c1e84667..06b08fe4f66 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service_external_state.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service_external_state.cpp @@ -115,7 +115,7 @@ ChunkManager RecipientStateMachineExternalStateImpl::getShardedCollectionRouting MigrationDestinationManager::CollectionOptionsAndUUID RecipientStateMachineExternalStateImpl::getCollectionOptions(OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) { // Load the collection options from the primary shard for the database. @@ -133,7 +133,7 @@ RecipientStateMachineExternalStateImpl::getCollectionOptions(OperationContext* o MigrationDestinationManager::IndexesAndIdIndex RecipientStateMachineExternalStateImpl::getCollectionIndexes(OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) { // Load the list of indexes from the shard which owns the global minimum chunk. diff --git a/src/mongo/db/s/resharding/resharding_recipient_service_external_state.h b/src/mongo/db/s/resharding/resharding_recipient_service_external_state.h index b1c9b922459..c1597da7f7c 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service_external_state.h +++ b/src/mongo/db/s/resharding/resharding_recipient_service_external_state.h @@ -70,14 +70,14 @@ public: virtual MigrationDestinationManager::CollectionOptionsAndUUID getCollectionOptions( OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) = 0; virtual MigrationDestinationManager::IndexesAndIdIndex getCollectionIndexes( OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) = 0; @@ -118,13 +118,13 @@ public: MigrationDestinationManager::CollectionOptionsAndUUID getCollectionOptions( OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) override; MigrationDestinationManager::IndexesAndIdIndex getCollectionIndexes(OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) override; diff --git a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp index d80f9487447..22a9840a450 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp @@ -105,7 +105,7 @@ public: MigrationDestinationManager::CollectionOptionsAndUUID getCollectionOptions( OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) override { invariant(nss == _sourceNss); @@ -115,7 +115,7 @@ public: MigrationDestinationManager::IndexesAndIdIndex getCollectionIndexes( OperationContext* opCtx, const NamespaceString& nss, - const CollectionUUID& uuid, + const UUID& uuid, Timestamp afterClusterTime, StringData reason) override { invariant(nss == _sourceNss); @@ -146,7 +146,7 @@ private: const StringData _currentShardKey = "oldKey"; const NamespaceString _sourceNss{"sourcedb", "sourcecollection"}; - const CollectionUUID _sourceUUID = UUID::gen(); + const UUID _sourceUUID = UUID::gen(); const ShardId _someDonorId{"myDonorId"}; }; diff --git a/src/mongo/db/s/shard_server_op_observer.cpp b/src/mongo/db/s/shard_server_op_observer.cpp index a81879f8058..cff62e2d7a1 100644 --- a/src/mongo/db/s/shard_server_op_observer.cpp +++ b/src/mongo/db/s/shard_server_op_observer.cpp @@ -601,7 +601,7 @@ repl::OpTime ShardServerOpObserver::onDropCollection(OperationContext* opCtx, void ShardServerOpObserver::onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) { diff --git a/src/mongo/db/s/shard_server_op_observer.h b/src/mongo/db/s/shard_server_op_observer.h index c833187cdd6..8dabf371829 100644 --- a/src/mongo/db/s/shard_server_op_observer.h +++ b/src/mongo/db/s/shard_server_op_observer.h @@ -47,13 +47,13 @@ public: void onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID uuid, + const UUID& uuid, BSONObj indexDoc, bool fromMigrate) override {} void onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override; @@ -64,14 +64,14 @@ public: void onCommitIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, bool fromMigrate) override {} void onAbortIndexBuild(OperationContext* opCtx, const NamespaceString& nss, - CollectionUUID collUUID, + const UUID& collUUID, const UUID& indexBuildUUID, const std::vector<BSONObj>& indexes, const Status& cause, @@ -99,7 +99,7 @@ public: void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, - OptionalCollectionUUID uuid, + const boost::optional<UUID>& uuid, const BSONObj& msgObj, const boost::optional<BSONObj> o2MsgObj, const boost::optional<repl::OpTime> preImageOpTime, @@ -141,7 +141,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override {} @@ -159,7 +159,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, bool stayTemp) override { return repl::OpTime(); @@ -168,7 +168,7 @@ public: const NamespaceString& fromCollection, const NamespaceString& toCollection, const UUID& uuid, - OptionalCollectionUUID dropTargetUUID, + const boost::optional<UUID>& dropTargetUUID, bool stayTemp) override {} void onApplyOps(OperationContext* opCtx, diff --git a/src/mongo/db/storage/durable_catalog_impl.cpp b/src/mongo/db/storage/durable_catalog_impl.cpp index 6d2b3535f6d..bfb9aa8b009 100644 --- a/src/mongo/db/storage/durable_catalog_impl.cpp +++ b/src/mongo/db/storage/durable_catalog_impl.cpp @@ -599,7 +599,7 @@ StatusWith<std::string> DurableCatalogImpl::newOrphanedIdent(OperationContext* o // Generate a new UUID for the orphaned collection. CollectionOptions optionsWithUUID; - optionsWithUUID.uuid.emplace(CollectionUUID::gen()); + optionsWithUUID.uuid.emplace(UUID::gen()); BSONObj obj; { BSONObjBuilder b; @@ -661,7 +661,7 @@ StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl return status; auto ru = opCtx->recoveryUnit(); - CollectionUUID uuid = options.uuid.get(); + UUID uuid = options.uuid.get(); opCtx->recoveryUnit()->onRollback([ru, catalog = this, nss, ident = entry.ident, uuid]() { // Intentionally ignoring failure catalog->_engine->getEngine()->dropIdent(ru, ident).ignore(); @@ -716,7 +716,7 @@ StatusWith<DurableCatalog::ImportResult> DurableCatalogImpl::importCollection( const auto& catalogEntry = [&] { if (uuidOption == ImportCollectionUUIDOption::kGenerateNew) { // Generate a new UUID for the collection. - md.options.uuid = CollectionUUID::gen(); + md.options.uuid = UUID::gen(); BSONObjBuilder catalogEntryBuilder; // Generate a new "md" field after setting the new UUID. catalogEntryBuilder.append("md", md.toBSON()); diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp index 431ec416cc5..9cd0bd8318b 100644 --- a/src/mongo/db/storage/kv/durable_catalog_test.cpp +++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp @@ -86,7 +86,7 @@ public: operationContext(), *_collectionUUID, CollectionCatalog::LifetimeMode::kInplace); } - CollectionUUID createCollection(const NamespaceString& nss, CollectionOptions options) { + UUID createCollection(const NamespaceString& nss, CollectionOptions options) { Lock::DBLock dbLk(operationContext(), nss.db(), MODE_IX); Lock::CollectionLock collLk(operationContext(), nss, MODE_IX); @@ -205,7 +205,7 @@ private: size_t _numIndexesCreated = 0; - OptionalCollectionUUID _collectionUUID; + boost::optional<UUID> _collectionUUID; }; TEST_F(DurableCatalogTest, MultikeyPathsForBtreeIndexInitializedToVectorOfEmptySets) { diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.cpp b/src/mongo/embedded/index_builds_coordinator_embedded.cpp index 7f2ca76690e..d541528a492 100644 --- a/src/mongo/embedded/index_builds_coordinator_embedded.cpp +++ b/src/mongo/embedded/index_builds_coordinator_embedded.cpp @@ -45,7 +45,7 @@ void IndexBuildsCoordinatorEmbedded::shutdown(OperationContext* opCtx) {} StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> IndexBuildsCoordinatorEmbedded::startIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, @@ -78,7 +78,7 @@ IndexBuildsCoordinatorEmbedded::startIndexBuild(OperationContext* opCtx, StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> IndexBuildsCoordinatorEmbedded::resumeIndexBuild(OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo) { diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.h b/src/mongo/embedded/index_builds_coordinator_embedded.h index c2ec6b77b88..50e6be8a725 100644 --- a/src/mongo/embedded/index_builds_coordinator_embedded.h +++ b/src/mongo/embedded/index_builds_coordinator_embedded.h @@ -59,7 +59,7 @@ public: StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> startIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, IndexBuildProtocol protocol, @@ -68,7 +68,7 @@ public: StatusWith<SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats>> resumeIndexBuild( OperationContext* opCtx, std::string dbName, - CollectionUUID collectionUUID, + const UUID& collectionUUID, const std::vector<BSONObj>& specs, const UUID& buildUUID, const ResumeIndexInfo& resumeInfo) override; diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp index 12d4f80c1bd..a5d97cf831e 100644 --- a/src/mongo/s/catalog/type_chunk.cpp +++ b/src/mongo/s/catalog/type_chunk.cpp @@ -207,10 +207,7 @@ StatusWith<std::vector<ChunkHistory>> ChunkHistory::fromBSON(const BSONArray& so ChunkType::ChunkType() = default; -ChunkType::ChunkType(CollectionUUID collectionUUID, - ChunkRange range, - ChunkVersion version, - ShardId shardId) +ChunkType::ChunkType(UUID collectionUUID, ChunkRange range, ChunkVersion version, ShardId shardId) : _collectionUUID(collectionUUID), _min(range.getMin()), _max(range.getMax()), @@ -455,7 +452,7 @@ void ChunkType::setName(const OID& id) { _id = id; } -void ChunkType::setCollectionUUID(const CollectionUUID& uuid) { +void ChunkType::setCollectionUUID(const UUID& uuid) { _collectionUUID = uuid; } diff --git a/src/mongo/s/catalog/type_chunk.h b/src/mongo/s/catalog/type_chunk.h index fdf27fd67ef..3b226f87598 100644 --- a/src/mongo/s/catalog/type_chunk.h +++ b/src/mongo/s/catalog/type_chunk.h @@ -213,10 +213,7 @@ public: static const BSONField<long long> estimatedSizeBytes; ChunkType(); - ChunkType(CollectionUUID collectionUUID, - ChunkRange range, - ChunkVersion version, - ShardId shardId); + ChunkType(UUID collectionUUID, ChunkRange range, ChunkVersion version, ShardId shardId); /** * Constructs a new ChunkType object from BSON that has the config server's config.chunks @@ -270,11 +267,11 @@ public: return (bool)_collectionUUID; } - const CollectionUUID& getCollectionUUID() const { + const UUID& getCollectionUUID() const { invariant(_collectionUUID); return *_collectionUUID; } - void setCollectionUUID(const CollectionUUID& uuid); + void setCollectionUUID(const UUID& uuid); const BSONObj& getMin() const { return _min.get(); @@ -343,7 +340,7 @@ private: // (M)(C) auto-generated object id boost::optional<OID> _id; // (O)(C) uuid of the collection in the CollectionCatalog - boost::optional<CollectionUUID> _collectionUUID; + boost::optional<UUID> _collectionUUID; // (M)(C)(S) first key of the range, inclusive boost::optional<BSONObj> _min; // (M)(C)(S) last key of the range, non-inclusive |