diff options
Diffstat (limited to 'src')
-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())) |