summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index e58330d61c4..66bbbd756b2 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -2195,13 +2195,19 @@ bool CollectionImpl::setIndexIsMultikey(OperationContext* opCtx,
uncommittedMultikeys = std::make_shared<UncommittedMultikey::MultikeyMap>();
}
BSONCollectionCatalogEntry::MetaData* metadata = nullptr;
+ bool hasSetMultikey = false;
if (auto it = uncommittedMultikeys->find(this); it != uncommittedMultikeys->end()) {
metadata = &it->second;
+ hasSetMultikey = setMultikey(*metadata);
} else {
- metadata = &uncommittedMultikeys->emplace(this, *_metadata).first->second;
+ BSONCollectionCatalogEntry::MetaData metadataLocal(*_metadata);
+ hasSetMultikey = setMultikey(metadataLocal);
+ if (hasSetMultikey) {
+ metadata = &uncommittedMultikeys->emplace(this, std::move(metadataLocal)).first->second;
+ }
}
- if (!setMultikey(*metadata))
+ if (!hasSetMultikey)
return false;
opCtx->recoveryUnit()->onRollback(