summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Suarez <ksuarz@gmail.com>2016-04-12 13:32:31 -0400
committerKyle Suarez <ksuarz@gmail.com>2016-04-15 22:40:13 -0400
commit9f3da9f28f1179ff0ee1171b6e714f553e793165 (patch)
tree783574512b83cbbad7a57632bf839c0d0eb9a1a2
parent9debc3589cde4594cb20dd0d78417b6950a56d72 (diff)
downloadmongo-9f3da9f28f1179ff0ee1171b6e714f553e793165.tar.gz
SERVER-23655 invalidate CollectionInfoCache on index build
This forces a rebuild of a collection's info cache once an index build has started, rather than waiting until the build has completed. This way, updates occurring while a background index build is in progress correctly know that the index will be affected and perform the update accordingly.
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 8662eb0f906..b572a66426e 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -365,6 +365,11 @@ Status IndexCatalog::IndexBuildBlock::init() {
const bool initFromDisk = false;
_entry = _catalog->_setupInMemoryStructures(_txn, descriptorCleaner.release(), initFromDisk);
+ // Register this index with the CollectionInfoCache to regenerate the cache. This way, updates
+ // occurring while an index is being build in the background will be aware of whether or not
+ // they need to modify any indexes.
+ _collection->infoCache()->addedIndex(_txn, descriptor);
+
return Status::OK();
}
@@ -413,8 +418,6 @@ void IndexCatalog::IndexBuildBlock::success() {
});
entry->setIsReady(true);
-
- collection->infoCache()->addedIndex(_txn, desc);
}
namespace {