diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-07-11 18:37:42 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-07-15 13:30:02 -0400 |
commit | 70a3df4dd5d102b2370a871c9182be281100a487 (patch) | |
tree | 4101519c5505800900caf30b1730c5fc6cdaeb5a /src/mongo/db/catalog/database_impl.cpp | |
parent | bb4ba528dd4254c33ac77026f94bc287b590ff3c (diff) | |
download | mongo-70a3df4dd5d102b2370a871c9182be281100a487.tar.gz |
SERVER-42194 Make Collection always hold a UUID (rather than optional UUID)
Diffstat (limited to 'src/mongo/db/catalog/database_impl.cpp')
-rw-r--r-- | src/mongo/db/catalog/database_impl.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index 1388714f3f7..d5c57cc8db4 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -348,13 +348,12 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, auto numRecords = collection->numRecords(opCtx); auto uuid = collection->uuid(); - auto uuidString = uuid ? uuid.get().toString() : "no UUID"; // Make sure no indexes builds are in progress. // Use massert() to be consistent with IndexCatalog::dropAllIndexes(). auto numIndexesInProgress = collection->getIndexCatalog()->numIndexesInProgress(opCtx); massert(ErrorCodes::BackgroundOperationInProgressForNamespace, - str::stream() << "cannot drop collection " << nss << " (" << uuidString << ") when " + str::stream() << "cannot drop collection " << nss << " (" << uuid << ") when " << numIndexesInProgress << " index builds in progress.", numIndexesInProgress == 0); @@ -385,7 +384,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, _dropCollectionIndexes(opCtx, nss, collection); auto commitTimestamp = opCtx->recoveryUnit()->getCommitTimestamp(); - log() << "dropCollection: " << nss << " (" << uuidString + log() << "dropCollection: " << nss << " (" << uuid << ") - storage engine will take ownership of drop-pending collection with optime " << dropOpTime << " and commit timestamp " << commitTimestamp; if (dropOpTime.isNull()) { @@ -425,7 +424,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, // Rename collection using drop-pending namespace generated from drop optime. auto dpns = nss.makeDropPendingNamespace(dropOpTime); const bool stayTemp = true; - log() << "dropCollection: " << nss << " (" << uuidString + log() << "dropCollection: " << nss << " (" << uuid << ") - renaming to drop-pending collection: " << dpns << " with drop optime " << dropOpTime; { @@ -454,7 +453,7 @@ void DatabaseImpl::_dropCollectionIndexes(OperationContext* opCtx, Status DatabaseImpl::_finishDropCollection(OperationContext* opCtx, const NamespaceString& nss, Collection* collection) const { - UUID uuid = *collection->uuid(); + UUID uuid = collection->uuid(); log() << "Finishing collection drop for " << nss << " (" << uuid << ")."; auto status = DurableCatalog::get(opCtx)->dropCollection(opCtx, nss); @@ -507,8 +506,8 @@ Status DatabaseImpl::renameCollection(OperationContext* opCtx, << toNss); } - log() << "renameCollection: renaming collection " << collToRename->uuid()->toString() - << " from " << fromNss << " to " << toNss; + log() << "renameCollection: renaming collection " << collToRename->uuid() << " from " << fromNss + << " to " << toNss; Top::get(opCtx->getServiceContext()).collectionDropped(fromNss); @@ -651,7 +650,7 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx, }); auto& catalog = CollectionCatalog::get(opCtx); - auto uuid = ownedCollection->uuid().get(); + auto uuid = ownedCollection->uuid(); catalog.registerCollection(uuid, std::move(ownedCollection)); opCtx->recoveryUnit()->onRollback([uuid, &catalog] { catalog.deregisterCollection(uuid); }); |