diff options
Diffstat (limited to 'src/mongo/db/catalog/index_catalog_impl.cpp')
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 709b7113311..0d3ed9abda6 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -1226,17 +1226,20 @@ const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx, invariant(_collection->getCatalogEntry()->isIndexReady(opCtx, indexName)); // Delete the IndexCatalogEntry that owns this descriptor. After deletion, 'oldDesc' is - // invalid and should not be dereferenced. + // invalid and should not be dereferenced. Also, invalidate the index from the + // CollectionInfoCache. auto oldEntry = _readyIndexes.release(oldDesc); invariant(oldEntry); opCtx->recoveryUnit()->registerChange( new IndexRemoveChange(opCtx, _collection, &_readyIndexes, std::move(oldEntry))); + _collection->infoCache()->droppedIndex(opCtx, indexName); // Ask the CollectionCatalogEntry for the new index spec. BSONObj spec = _collection->getCatalogEntry()->getIndexSpec(opCtx, indexName).getOwned(); BSONObj keyPattern = spec.getObjectField("key"); - // Re-register this index in the index catalog with the new spec. + // Re-register this index in the index catalog with the new spec. Also, add the new index + // to the CollectionInfoCache. auto newDesc = std::make_unique<IndexDescriptor>(_collection, _getAccessMethodName(keyPattern), spec); const bool initFromDisk = false; @@ -1244,6 +1247,7 @@ const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx, const IndexCatalogEntry* newEntry = _setupInMemoryStructures(opCtx, std::move(newDesc), initFromDisk, isReadyIndex); invariant(newEntry->isReady(opCtx)); + _collection->infoCache()->addedIndex(opCtx, newEntry->descriptor()); // Return the new descriptor. return newEntry->descriptor(); |