diff options
author | Maria van Keulen <maria@mongodb.com> | 2019-06-18 14:38:58 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-02 20:33:12 +0000 |
commit | 2a5be0c44b33f618dae743ccee344b00dcf76ef1 (patch) | |
tree | bcfcc6573acd5da74a8ca052dfe7ec7a0b4aada6 | |
parent | 33034f28784b53d12c9c733ac63b8920ec8bc9c9 (diff) | |
download | mongo-2a5be0c44b33f618dae743ccee344b00dcf76ef1.tar.gz |
SERVER-41600 Invalidate index from CollectionInfoCache in refreshEntry
(cherry picked from commit 5f21969e6ca6c7805df0165ff81677aed1199958)
-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 fd5e30b9413..c38824e0a56 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -1290,22 +1290,26 @@ const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx, str::stream() << "definition of index '" << indexName << "' changed"); // 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. IndexCatalogEntry* oldEntry = _entries.release(oldDesc); opCtx->recoveryUnit()->registerChange( new IndexRemoveChange(opCtx, _collection, &_entries, 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 = stdx::make_unique<IndexDescriptor>( _collection, _getAccessMethodName(opCtx, keyPattern), spec); const bool initFromDisk = false; const IndexCatalogEntry* newEntry = _setupInMemoryStructures(opCtx, std::move(newDesc), initFromDisk); invariant(newEntry->isReady(opCtx)); + _collection->infoCache()->addedIndex(opCtx, newEntry->descriptor()); // Return the new descriptor. return newEntry->descriptor(); |