summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorHaley Connelly <haley.connelly@10gen.com>2019-09-20 18:00:07 +0000
committerevergreen <evergreen@mongodb.com>2019-09-20 18:00:07 +0000
commit00bd5405dfaa44f3094965cf6bb0e6dc55062b99 (patch)
tree79b8db398ff61efe6493b67cc1f110105db8988b /src/mongo/db/catalog
parentb21c2f2741682591b925841aea131bc3dce3de9a (diff)
downloadmongo-00bd5405dfaa44f3094965cf6bb0e6dc55062b99.tar.gz
SERVER-42373 Prevent "invalid view definition" error while dropping nonexistent collection
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index e3f9f9795ab..107e9b7ddad 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -59,10 +59,15 @@ Status _dropView(OperationContext* opCtx,
if (!db) {
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
- auto view = ViewCatalog::get(db)->lookup(opCtx, collectionName.ns());
+ auto view =
+ ViewCatalog::get(db)->lookupWithoutValidatingDurableViews(opCtx, collectionName.ns());
if (!view) {
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
+
+ // Validates the view or throws an "invalid view" error.
+ ViewCatalog::get(db)->lookup(opCtx, collectionName.ns());
+
Lock::CollectionLock collLock(opCtx, collectionName, MODE_IX);
// Operations all lock system.views in the end to prevent deadlock.
Lock::CollectionLock systemViewsLock(opCtx, db->getSystemViewsName(), MODE_X);