diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2021-05-11 14:30:26 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-20 19:18:53 +0000 |
commit | 11de948b0c50df7d12de09ae0f01e791fc5d70d7 (patch) | |
tree | 5a5a89cce0dc94f21778725184f8da3d5f76a13b /src/mongo/db/index | |
parent | b2802257c7cd2cf253847d67da5ddcc780a5b85f (diff) | |
download | mongo-11de948b0c50df7d12de09ae0f01e791fc5d70d7.tar.gz |
SERVER-56002 SERVER-56023 Store Collection metadata in the Collection and reply on the copy-on-write machinery to keep it in sync with the durable catalog.
All updates to the metadata needs to happen through the Collection, moved interfaces from the DurableCatalog to the Collection.
Removed back pointer to Collection in IndexCatalogEntryImpl, interfaces now correctly take a const or non-const Collection. This should make its iterface const-correct to avoid making bugs where the copy-on-write system for Collections are bypassed.
Multikey handle is special as it needs to happen without exclusive access to the Collection. Implemented isolation for the Collection metadata when multikey is changed. It handles multi-doc transactions and is only commited to the Collection instance after the write to the durable catalog successfully commits.
listCollections and listIndexes can now safetly read the metadata cache without needing to read from the durable catalog making them safe to do without Collection level locks.
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 8 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 57a609f1afd..b906b593150 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -50,7 +50,6 @@ #include "mongo/db/operation_context.h" #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/timestamp_block.h" -#include "mongo/db/storage/durable_catalog.h" #include "mongo/db/storage/execution_context.h" #include "mongo/db/storage/storage_options.h" #include "mongo/logv2/log.h" @@ -108,7 +107,7 @@ struct BtreeExternalSortComparison { } }; -AbstractIndexAccessMethod::AbstractIndexAccessMethod(IndexCatalogEntry* btreeState, +AbstractIndexAccessMethod::AbstractIndexAccessMethod(const IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree) : _indexCatalogEntry(btreeState), _descriptor(btreeState->descriptor()), @@ -377,7 +376,7 @@ pair<KeyStringSet, KeyStringSet> AbstractIndexAccessMethod::setDifference( } void AbstractIndexAccessMethod::prepareUpdate(OperationContext* opCtx, - IndexCatalogEntry* index, + const IndexCatalogEntry* index, const BSONObj& from, const BSONObj& to, const RecordId& record, @@ -476,11 +475,11 @@ Status AbstractIndexAccessMethod::compact(OperationContext* opCtx) { class AbstractIndexAccessMethod::BulkBuilderImpl : public IndexAccessMethod::BulkBuilder { public: - BulkBuilderImpl(IndexCatalogEntry* indexCatalogEntry, + BulkBuilderImpl(const IndexCatalogEntry* indexCatalogEntry, size_t maxMemoryUsageBytes, StringData dbName); - BulkBuilderImpl(IndexCatalogEntry* index, + BulkBuilderImpl(const IndexCatalogEntry* index, size_t maxMemoryUsageBytes, const IndexStateInfo& stateInfo, StringData dbName); @@ -515,7 +514,7 @@ private: Sorter::Settings _makeSorterSettings() const; - IndexCatalogEntry* _indexCatalogEntry; + const IndexCatalogEntry* _indexCatalogEntry; std::unique_ptr<Sorter> _sorter; int64_t _keysInserted = 0; @@ -542,12 +541,12 @@ std::unique_ptr<IndexAccessMethod::BulkBuilder> AbstractIndexAccessMethod::initi : std::make_unique<BulkBuilderImpl>(_indexCatalogEntry, maxMemoryUsageBytes, dbName); } -AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(IndexCatalogEntry* index, +AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEntry* index, size_t maxMemoryUsageBytes, StringData dbName) : _indexCatalogEntry(index), _sorter(_makeSorter(maxMemoryUsageBytes, dbName)) {} -AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(IndexCatalogEntry* index, +AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexCatalogEntry* index, size_t maxMemoryUsageBytes, const IndexStateInfo& stateInfo, StringData dbName) diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 5e3c9376ea7..417af5798b0 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -138,7 +138,7 @@ public: * Provides a ticket for actually performing the update. */ virtual void prepareUpdate(OperationContext* opCtx, - IndexCatalogEntry* index, + const IndexCatalogEntry* index, const BSONObj& from, const BSONObj& to, const RecordId& loc, @@ -454,7 +454,7 @@ public: static std::pair<KeyStringSet, KeyStringSet> setDifference(const KeyStringSet& left, const KeyStringSet& right); - AbstractIndexAccessMethod(IndexCatalogEntry* btreeState, + AbstractIndexAccessMethod(const IndexCatalogEntry* btreeState, std::unique_ptr<SortedDataInterface> btree); Status insert(OperationContext* opCtx, @@ -490,7 +490,7 @@ public: int64_t* numDeleted) final; void prepareUpdate(OperationContext* opCtx, - IndexCatalogEntry* index, + const IndexCatalogEntry* index, const BSONObj& from, const BSONObj& to, const RecordId& loc, @@ -579,7 +579,7 @@ protected: MultikeyPaths* multikeyPaths, boost::optional<RecordId> id) const = 0; - IndexCatalogEntry* const _indexCatalogEntry; // owned by IndexCatalog + const IndexCatalogEntry* const _indexCatalogEntry; // owned by IndexCatalog const IndexDescriptor* const _descriptor; private: |