diff options
author | Benety Goh <benety@mongodb.com> | 2021-07-19 17:54:33 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-19 22:18:26 +0000 |
commit | faaca3440968820be133979d503bbe048eb69e4b (patch) | |
tree | 3ece809c6dd6fc3e6d96e1a048bf2cdcb6e129b8 /src/mongo/db/repl/storage_interface_impl.cpp | |
parent | a16078a291010137916a3c496bc5e423fe55e0e6 (diff) | |
download | mongo-faaca3440968820be133979d503bbe048eb69e4b.tar.gz |
SERVER-58385 StorageInterface::setIndexIsMultikey() accepts collection UUID
Diffstat (limited to 'src/mongo/db/repl/storage_interface_impl.cpp')
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 7f99a956cbf..b19cea8c2f3 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -591,6 +591,7 @@ Status StorageInterfaceImpl::renameCollection(OperationContext* opCtx, Status StorageInterfaceImpl::setIndexIsMultikey(OperationContext* opCtx, const NamespaceString& nss, + const UUID& collectionUUID, const std::string& indexName, const KeyStringSet& multikeyMetadataKeys, const MultikeyPaths& paths, @@ -598,13 +599,19 @@ Status StorageInterfaceImpl::setIndexIsMultikey(OperationContext* opCtx, if (ts.isNull()) { return Status(ErrorCodes::InvalidOptions, str::stream() << "Cannot set index " << indexName << " on " << nss.ns() - << " as multikey at null timestamp"); + << " (" << collectionUUID << ") as multikey at null timestamp"); } return writeConflictRetry(opCtx, "StorageInterfaceImpl::setIndexIsMultikey", nss.ns(), [&] { - AutoGetCollection autoColl(opCtx, nss, MODE_IX); + const NamespaceStringOrUUID nsOrUUID(nss); + boost::optional<AutoGetCollection> autoColl; + try { + autoColl.emplace(opCtx, nsOrUUID, MODE_IX); + } catch (ExceptionFor<ErrorCodes::NamespaceNotFound>& ex) { + return ex.toStatus(); + } auto collectionResult = getCollection( - autoColl, nss, "The collection must exist before setting an index to multikey."); + *autoColl, nsOrUUID, "The collection must exist before setting an index to multikey."); if (!collectionResult.isOK()) { return collectionResult.getStatus(); } @@ -620,8 +627,9 @@ Status StorageInterfaceImpl::setIndexIsMultikey(OperationContext* opCtx, opCtx, indexName, true /* includeUnfinishedIndexes */); if (!idx) { return Status(ErrorCodes::IndexNotFound, - str::stream() << "Could not find index " << indexName << " in " - << nss.ns() << " to set to multikey."); + str::stream() + << "Could not find index " << indexName << " in " << nss.ns() << " (" + << collectionUUID << ") to set to multikey."); } collection->getIndexCatalog()->setMultikeyPaths( opCtx, collection, idx, multikeyMetadataKeys, paths); |