summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/database.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog/database.cpp')
-rw-r--r--src/mongo/db/catalog/database.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index 9b68549f295..13b4b7faa01 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -315,14 +315,8 @@ void Database::getStats(OperationContext* opCtx, BSONObjBuilder* output, double
}
Status Database::dropCollection(OperationContext* txn, StringData fullns) {
- invariant(txn->lockState()->isDbLockedForMode(name(), MODE_X));
-
- LOG(1) << "dropCollection: " << fullns << endl;
- massertNamespaceNotIndex(fullns, "dropCollection");
-
- Collection* collection = getCollection(fullns);
- if (!collection) {
- // collection doesn't exist
+ if (!getCollection(fullns)) {
+ // Collection doesn't exist so don't bother validating if it can be dropped.
return Status::OK();
}
@@ -341,9 +335,24 @@ Status Database::dropCollection(OperationContext* txn, StringData fullns) {
}
}
+ return dropCollectionEvenIfSystem(txn, nss);
+}
+
+Status Database::dropCollectionEvenIfSystem(OperationContext* txn, const NamespaceString& fullns) {
+ invariant(txn->lockState()->isDbLockedForMode(name(), MODE_X));
+
+ LOG(1) << "dropCollection: " << fullns;
+
+ Collection* collection = getCollection(fullns);
+ if (!collection) {
+ return Status::OK(); // Post condition already met.
+ }
+
+ massertNamespaceNotIndex(fullns.toString(), "dropCollection");
+
BackgroundOperation::assertNoBgOpInProgForNs(fullns);
- audit::logDropCollection(&cc(), fullns);
+ audit::logDropCollection(&cc(), fullns.toString());
Status s = collection->getIndexCatalog()->dropAllIndexes(txn, true);
if (!s.isOK()) {
@@ -355,13 +364,13 @@ Status Database::dropCollection(OperationContext* txn, StringData fullns) {
verify(collection->_details->getTotalIndexCount(txn) == 0);
LOG(1) << "\t dropIndexes done" << endl;
- Top::get(txn->getClient()->getServiceContext()).collectionDropped(fullns);
+ Top::get(txn->getClient()->getServiceContext()).collectionDropped(fullns.toString());
// We want to destroy the Collection object before telling the StorageEngine to destroy the
// RecordStore.
- _clearCollectionCache(txn, fullns, "collection dropped");
+ _clearCollectionCache(txn, fullns.toString(), "collection dropped");
- s = _dbEntry->dropCollection(txn, fullns);
+ s = _dbEntry->dropCollection(txn, fullns.toString());
if (!s.isOK())
return s;
@@ -378,7 +387,7 @@ Status Database::dropCollection(OperationContext* txn, StringData fullns) {
}
}
- getGlobalServiceContext()->getOpObserver()->onDropCollection(txn, nss);
+ getGlobalServiceContext()->getOpObserver()->onDropCollection(txn, fullns);
return Status::OK();
}