diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-11-01 15:06:23 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-01 15:06:23 +0000 |
commit | 384292b85cbf344602b377a81821d7b1924b978e (patch) | |
tree | 8152ffa8a29465b84eeb842277ae996fb6c6f2e0 /src/mongo/db/commands/drop_indexes.cpp | |
parent | 266ce1569a5c1fba667e865d5143172ce4f80d57 (diff) | |
download | mongo-384292b85cbf344602b377a81821d7b1924b978e.tar.gz |
SERVER-44026 Remove global X lock for reIndex
Diffstat (limited to 'src/mongo/db/commands/drop_indexes.cpp')
-rw-r--r-- | src/mongo/db/commands/drop_indexes.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index 45db3f44786..9c6e5394797 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -128,18 +128,10 @@ public: LOG(0) << "CMD: reIndex " << toReIndexNss; - // This Global write lock is necessary to ensure no other connections establish a snapshot - // while the reIndex command is running. The reIndex command does not write oplog entries - // (for the most part) and thus the minimumVisibleSnapshot mechanism doesn't completely - // avoid reading at times that may show discrepancies between the in-memory index catalog - // and the on-disk index catalog. - Lock::GlobalWrite lk(opCtx); - AutoGetOrCreateDb autoDb(opCtx, dbname, MODE_X); - - Collection* collection = - CollectionCatalog::get(opCtx).lookupCollectionByNamespace(toReIndexNss); + AutoGetCollection autoColl(opCtx, toReIndexNss, MODE_X); + Collection* collection = autoColl.getCollection(); if (!collection) { - if (ViewCatalog::get(autoDb.getDb())->lookup(opCtx, toReIndexNss.ns())) + if (ViewCatalog::get(autoColl.getDb())->lookup(opCtx, toReIndexNss.ns())) uasserted(ErrorCodes::CommandNotSupportedOnView, "can't re-index a view"); else uasserted(ErrorCodes::NamespaceNotFound, "collection does not exist"); @@ -203,6 +195,7 @@ public: result.appendNumber("nIndexesWas", all.size()); std::unique_ptr<MultiIndexBlock> indexer = std::make_unique<MultiIndexBlock>(); + indexer->setIndexBuildMethod(IndexBuildMethod::kForeground); StatusWith<std::vector<BSONObj>> swIndexesToRebuild(ErrorCodes::UnknownError, "Uninitialized"); |