summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorXiangyu Yao <xiangyu.yao@mongodb.com>2019-05-31 11:49:39 -0400
committerXiangyu Yao <xiangyu.yao@mongodb.com>2019-06-05 20:05:48 -0400
commit441348f68c71d70723b2abd63488d7d3906f3d8b (patch)
treeef1a217e64849c4dd2a99d1d84f845bfb3fde593 /src/mongo/db/catalog
parent43b787e5b5636dbfcd0332be8e96feb32992c00b (diff)
downloadmongo-441348f68c71d70723b2abd63488d7d3906f3d8b.tar.gz
SERVER-41426 StorageInterface's dropCollection should only take Database IX lock
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 6cf54a572ad..647f70947f4 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -53,10 +53,9 @@ MONGO_FAIL_POINT_DEFINE(hangDropCollectionBeforeLockAcquisition);
MONGO_FAIL_POINT_DEFINE(hangDuringDropCollection);
Status _dropView(OperationContext* opCtx,
- std::unique_ptr<AutoGetDb>& autoDb,
+ Database* db,
const NamespaceString& collectionName,
BSONObjBuilder& result) {
- Database* db = autoDb->getDb();
if (!db) {
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
@@ -77,7 +76,7 @@ Status _dropView(OperationContext* opCtx,
collectionName,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurop,
- autoDb->getDb()->getProfilingLevel());
+ db->getProfilingLevel());
if (opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName)) {
@@ -161,17 +160,15 @@ Status dropCollection(OperationContext* opCtx,
MONGO_FAIL_POINT_PAUSE_WHILE_SET(hangDropCollectionBeforeLockAcquisition);
}
return writeConflictRetry(opCtx, "drop", collectionName.ns(), [&] {
- // TODO(SERVER-39520): Get rid of database MODE_X lock.
- auto autoDb = std::make_unique<AutoGetDb>(opCtx, collectionName.db(), MODE_IX);
-
- Database* db = autoDb->getDb();
+ AutoGetDb autoDb(opCtx, collectionName.db(), MODE_IX);
+ Database* db = autoDb.getDb();
if (!db) {
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
Collection* coll = db->getCollection(opCtx, collectionName);
if (!coll) {
- return _dropView(opCtx, autoDb, collectionName, result);
+ return _dropView(opCtx, db, collectionName, result);
} else {
return _dropCollection(
opCtx, db, collectionName, dropOpTime, systemCollectionMode, result);