diff options
Diffstat (limited to 'src/mongo/db/exec/requires_collection_stage.cpp')
-rw-r--r-- | src/mongo/db/exec/requires_collection_stage.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/exec/requires_collection_stage.cpp b/src/mongo/db/exec/requires_collection_stage.cpp index 060722dbe14..6c57f37574b 100644 --- a/src/mongo/db/exec/requires_collection_stage.cpp +++ b/src/mongo/db/exec/requires_collection_stage.cpp @@ -52,23 +52,24 @@ void RequiresCollectionStageBase<CollectionT>::doRestoreState() { dassert(getOpCtx()->lockState()->isCollectionLockedForMode(_nss, MODE_IS)); const CollectionCatalog& catalog = CollectionCatalog::get(getOpCtx()); - auto newNss = catalog.lookupNSSByUUID(_collectionUUID); + Collection* coll = nullptr; + boost::optional<NamespaceString> newNss; + std::tie(coll, newNss) = + catalog.lookupCollectionByUUIDAndVerifyNamespace(_collectionUUID, _nss); uassert(ErrorCodes::QueryPlanKilled, str::stream() << "collection dropped. UUID " << _collectionUUID, - newNss); + coll || newNss); // TODO SERVER-31695: Allow queries to survive collection rename, rather than throwing here when // a rename has happened during yield. uassert(ErrorCodes::QueryPlanKilled, str::stream() << "collection renamed from '" << _nss << "' to '" << *newNss << "'. UUID " << _collectionUUID, - *newNss == _nss); + coll); // At this point we know that the collection name has not changed, and therefore we have - // restored locks on the correct name. It is now safe to restore the Collection pointer. The - // collection must exist, since we already successfully looked up the namespace string by UUID - // under the correct lock manager locks. - _collection = catalog.lookupCollectionByUUID(_collectionUUID); + // restored locks on the correct name. + _collection = coll; invariant(_collection); uassert(ErrorCodes::QueryPlanKilled, |