diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-05-31 11:49:39 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-06-05 20:05:48 -0400 |
commit | 441348f68c71d70723b2abd63488d7d3906f3d8b (patch) | |
tree | ef1a217e64849c4dd2a99d1d84f845bfb3fde593 /src/mongo/db/catalog | |
parent | 43b787e5b5636dbfcd0332be8e96feb32992c00b (diff) | |
download | mongo-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.cpp | 13 |
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); |