diff options
author | Benety Goh <benety@mongodb.com> | 2021-11-03 19:44:01 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-04 00:24:08 +0000 |
commit | 058019e29ff1c96f09fa9c183f94bcd840126372 (patch) | |
tree | 79799c5af083d97bb8354d28f5e7df1ddb555f13 | |
parent | f64776b399ee0934724da0065541886c31da90f4 (diff) | |
download | mongo-058019e29ff1c96f09fa9c183f94bcd840126372.tar.gz |
SERVER-61158 IndexCatalog::refreshEntry() accepts CreateIndexEntryFlags
-rw-r--r-- | src/mongo/db/catalog/coll_mod.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/catalog/coll_mod_index.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog.h | 3 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.h | 3 | ||||
-rw-r--r-- | src/mongo/dbtests/indexcatalogtests.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/validate_tests.cpp | 3 |
7 files changed, 15 insertions, 9 deletions
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 4c8bbdbf40c..39fc50d4782 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -659,7 +659,7 @@ Status _collModInternal(OperationContext* opCtx, // Notify the index catalog that the definition of this index changed. coll.getWritableCollection()->getIndexCatalog()->refreshEntry( - opCtx, coll.getWritableCollection(), desc); + opCtx, coll.getWritableCollection(), desc, CreateIndexEntryFlags::kIsReady); } // TODO SERVER-60911: When kLatest is 5.3, only check when upgrading from or downgrading to diff --git a/src/mongo/db/catalog/coll_mod_index.cpp b/src/mongo/db/catalog/coll_mod_index.cpp index a9cf651155d..9fbf29bab63 100644 --- a/src/mongo/db/catalog/coll_mod_index.cpp +++ b/src/mongo/db/catalog/coll_mod_index.cpp @@ -203,10 +203,13 @@ void processCollModIndexRequest(OperationContext* opCtx, !indexUnique ? boost::optional<bool>() : newUnique.booleanSafe(), idx->indexName()}; + // This matches the default for IndexCatalog::refreshEntry(). + auto flags = CreateIndexEntryFlags::kIsReady; + // Notify the index catalog that the definition of this index changed. This will invalidate the // local idx pointer. On rollback of this WUOW, the local var idx pointer will be valid again. autoColl->getWritableCollection()->getIndexCatalog()->refreshEntry( - opCtx, autoColl->getWritableCollection(), idx); + opCtx, autoColl->getWritableCollection(), idx, flags); opCtx->recoveryUnit()->registerChange(std::make_unique<CollModResultChange>( oldExpireSecs, newExpireSecs, oldHidden, newHidden, newUnique, result)); diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h index 40588953820..624f0fe427c 100644 --- a/src/mongo/db/catalog/index_catalog.h +++ b/src/mongo/db/catalog/index_catalog.h @@ -279,7 +279,8 @@ public: */ virtual const IndexDescriptor* refreshEntry(OperationContext* opCtx, Collection* collection, - const IndexDescriptor* oldDesc) = 0; + const IndexDescriptor* oldDesc, + CreateIndexEntryFlags flags) = 0; /** * Returns a pointer to the index catalog entry associated with 'desc'. Throws if there is no diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 1bc87aee0e6..5e0c8b0f593 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -1317,7 +1317,8 @@ std::vector<std::shared_ptr<const IndexCatalogEntry>> IndexCatalogImpl::getAllRe const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx, Collection* collection, - const IndexDescriptor* oldDesc) { + const IndexDescriptor* oldDesc, + CreateIndexEntryFlags flags) { invariant(_buildingIndexes.size() == 0); const std::string indexName = oldDesc->indexName(); @@ -1340,8 +1341,7 @@ const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx, // Re-register this index in the index catalog with the new spec. Also, add the new index // to the CollectionIndexUsageTrackerDecoration (shared state among Collection instances). auto newDesc = std::make_unique<IndexDescriptor>(_getAccessMethodName(keyPattern), spec); - auto newEntry = - createIndexEntry(opCtx, collection, std::move(newDesc), CreateIndexEntryFlags::kIsReady); + auto newEntry = createIndexEntry(opCtx, collection, std::move(newDesc), flags); invariant(newEntry->isReady(opCtx, collection)); auto desc = newEntry->descriptor(); CollectionIndexUsageTrackerDecoration::get(collection->getSharedDecorations()) diff --git a/src/mongo/db/catalog/index_catalog_impl.h b/src/mongo/db/catalog/index_catalog_impl.h index 86f004761be..1e766198fce 100644 --- a/src/mongo/db/catalog/index_catalog_impl.h +++ b/src/mongo/db/catalog/index_catalog_impl.h @@ -161,7 +161,8 @@ public: */ const IndexDescriptor* refreshEntry(OperationContext* opCtx, Collection* collection, - const IndexDescriptor* oldDesc) override; + const IndexDescriptor* oldDesc, + CreateIndexEntryFlags flags) override; const IndexCatalogEntry* getEntry(const IndexDescriptor* desc) const override; diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp index 0afe4634f4f..7613292c9dd 100644 --- a/src/mongo/dbtests/indexcatalogtests.cpp +++ b/src/mongo/dbtests/indexcatalogtests.cpp @@ -216,7 +216,7 @@ public: { // Notify the catalog of the change. WriteUnitOfWork wuow(&opCtx); - desc = _catalog->refreshEntry(&opCtx, _coll, desc); + desc = _catalog->refreshEntry(&opCtx, _coll, desc, CreateIndexEntryFlags::kIsReady); wuow.commit(); } diff --git a/src/mongo/dbtests/validate_tests.cpp b/src/mongo/dbtests/validate_tests.cpp index 859348bd8d2..f16a038f845 100644 --- a/src/mongo/dbtests/validate_tests.cpp +++ b/src/mongo/dbtests/validate_tests.cpp @@ -3373,7 +3373,8 @@ public: { WriteUnitOfWork wunit(&_opCtx); auto writableCatalog = const_cast<IndexCatalog*>(indexCatalog); - descriptor = writableCatalog->refreshEntry(&_opCtx, writableCollection, descriptor); + descriptor = writableCatalog->refreshEntry( + &_opCtx, writableCollection, descriptor, CreateIndexEntryFlags::kIsReady); wunit.commit(); } |