diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-04-25 14:54:48 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-04-25 15:11:04 -0400 |
commit | 3a8c33cd95abaa7455b2c01726bdbf413cc938e5 (patch) | |
tree | 568bf26f33eaea6c5f6ccf87c2d58b438cd5fc0e /src/mongo/db/storage/kv/kv_catalog.cpp | |
parent | aa4903255505f9072581e8ea4c63b93093f04508 (diff) | |
download | mongo-3a8c33cd95abaa7455b2c01726bdbf413cc938e5.tar.gz |
SERVER-39520 Use database IX lock for dropCollection
Diffstat (limited to 'src/mongo/db/storage/kv/kv_catalog.cpp')
-rw-r--r-- | src/mongo/db/storage/kv/kv_catalog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp index d64df979a5c..534a83c9e40 100644 --- a/src/mongo/db/storage/kv/kv_catalog.cpp +++ b/src/mongo/db/storage/kv/kv_catalog.cpp @@ -581,7 +581,7 @@ Status KVCatalog::_replaceEntry(OperationContext* opCtx, } Status KVCatalog::_removeEntry(OperationContext* opCtx, StringData ns) { - invariant(opCtx->lockState()->isDbLockedForMode(nsToDatabaseSubstring(ns), MODE_X)); + invariant(opCtx->lockState()->isCollectionLockedForMode(NamespaceString(ns), MODE_X)); stdx::lock_guard<stdx::mutex> lk(_identsLock); const NSToIdentMap::iterator it = _idents.find(ns.toString()); if (it == _idents.end()) { @@ -793,7 +793,10 @@ Status KVCatalog::renameCollection(OperationContext* opCtx, bool stayTemp) { const NamespaceString fromNss(fromNS); const NamespaceString toNss(toNS); - invariant(opCtx->lockState()->isDbLockedForMode(fromNss.db(), MODE_X)); + // TODO SERVER-39518 : Temporarily comment this out because dropCollection uses + // this function and now it only takes a database IX lock. We can change + // this invariant to IX once renameCollection only MODE_IX as well. + // invariant(opCtx->lockState()->isDbLockedForMode(fromNss.db(), MODE_X)); const std::string identFrom = _engine->getCatalog()->getCollectionIdent(fromNS); @@ -836,7 +839,7 @@ private: Status KVCatalog::dropCollection(OperationContext* opCtx, StringData ns) { NamespaceString nss(ns); - invariant(opCtx->lockState()->isDbLockedForMode(nss.db(), MODE_X)); + invariant(opCtx->lockState()->isCollectionLockedForMode(nss, MODE_X)); CollectionCatalogEntry* const entry = UUIDCatalog::get(opCtx).lookupCollectionCatalogEntryByNamespace(nss); |