diff options
author | Maria van Keulen <maria@mongodb.com> | 2019-06-18 14:38:58 -0400 |
---|---|---|
committer | Maria van Keulen <maria@mongodb.com> | 2019-06-19 13:13:44 -0400 |
commit | 5f21969e6ca6c7805df0165ff81677aed1199958 (patch) | |
tree | c66487598ba266457ea21f8b7eef2f989d441d56 | |
parent | 46e086d2093798cdec949eba2919ccac88719166 (diff) | |
download | mongo-5f21969e6ca6c7805df0165ff81677aed1199958.tar.gz |
SERVER-41600 Invalidate index from CollectionInfoCache in refreshEntry
-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(); |