diff options
author | Eric Milkie <milkie@10gen.com> | 2018-06-13 09:17:09 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2018-06-13 11:03:52 -0400 |
commit | 09102565d15e386d09b16f0f257b8148622fb63c (patch) | |
tree | 5b04ae169138d89a12bbe9a35e27087f50289608 | |
parent | 527699b80481dba90e5b5aec386faa4b4aa20c86 (diff) | |
download | mongo-09102565d15e386d09b16f0f257b8148622fb63c.tar.gz |
SERVER-35569 reIndex should take a Global exclusive lock instead of just a Database lock
(cherry picked from commit 262a09efff3e9ef33cc56af1eed6a6d73afecc95)
-rw-r--r-- | src/mongo/db/commands/drop_indexes.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index 269319f0c7a..95452e0024c 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -127,7 +127,14 @@ 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 = autoDb.getDb()->getCollection(opCtx, toReIndexNss); if (!collection) { if (autoDb.getDb()->getViewCatalog()->lookup(opCtx, toReIndexNss.ns())) |