diff options
author | Benety Goh <benety@mongodb.com> | 2021-05-21 07:16:46 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-21 11:36:50 +0000 |
commit | 7e01c960ee3a2ecf32aa3745db93e1bef84d1030 (patch) | |
tree | 3a07bffa5741f640100bfdfd9b64dac201540438 /src | |
parent | c711ca8a619cd68cf26aceaf2a0e57aa64d3227c (diff) | |
download | mongo-7e01c960ee3a2ecf32aa3745db93e1bef84d1030.tar.gz |
Revert "SERVER-56877 IndexCatalogEntryImpl maintains separate copies of multikey paths for readers and writers"
This reverts commit bc095d5cef314bab9fd583c3908eb1cfecb49dd9.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/catalog/index_catalog_entry_impl.cpp | 19 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog_entry_impl.h | 4 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp index c20bc831c88..7ba3a22f1e4 100644 --- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp @@ -78,11 +78,10 @@ IndexCatalogEntryImpl::IndexCatalogEntryImpl(OperationContext* const opCtx, { stdx::lock_guard<Latch> lk(_indexMultikeyPathsMutex); - const bool isMultikey = _catalogIsMultikey(opCtx, collection, &_indexMultikeyPathsForWrite); + const bool isMultikey = _catalogIsMultikey(opCtx, collection, &_indexMultikeyPathsForRead); _isMultikeyForRead.store(isMultikey); _isMultikeyForWrite.store(isMultikey); - _indexMultikeyPathsForRead = _indexMultikeyPathsForWrite; - _indexTracksMultikeyPathsInCatalog = !_indexMultikeyPathsForWrite.empty(); + _indexTracksMultikeyPathsInCatalog = !_indexMultikeyPathsForRead.empty(); } auto nss = DurableCatalog::get(opCtx)->getEntry(_catalogId).nss; @@ -185,12 +184,12 @@ void IndexCatalogEntryImpl::setMultikey(OperationContext* opCtx, if (_indexTracksMultikeyPathsInCatalog) { stdx::lock_guard<Latch> lk(_indexMultikeyPathsMutex); - invariant(multikeyPaths.size() == _indexMultikeyPathsForWrite.size()); + invariant(multikeyPaths.size() == _indexMultikeyPathsForRead.size()); bool newPathIsMultikey = false; for (size_t i = 0; i < multikeyPaths.size(); ++i) { - if (!std::includes(_indexMultikeyPathsForWrite[i].begin(), - _indexMultikeyPathsForWrite[i].end(), + if (!std::includes(_indexMultikeyPathsForRead[i].begin(), + _indexMultikeyPathsForRead[i].end(), multikeyPaths[i].begin(), multikeyPaths[i].end())) { // If 'multikeyPaths' contains a new path component that causes this index to be @@ -275,11 +274,10 @@ void IndexCatalogEntryImpl::forceSetMultikey(OperationContext* const opCtx, { stdx::lock_guard<Latch> lk(_indexMultikeyPathsMutex); const bool isMultikeyInCatalog = - _catalogIsMultikey(opCtx, coll, &_indexMultikeyPathsForWrite); + _catalogIsMultikey(opCtx, coll, &_indexMultikeyPathsForRead); _isMultikeyForRead.store(isMultikeyInCatalog); _isMultikeyForWrite.store(isMultikeyInCatalog); - _indexMultikeyPathsForRead = _indexMultikeyPathsForWrite; - _indexTracksMultikeyPathsInCatalog = !_indexMultikeyPathsForWrite.empty(); + _indexTracksMultikeyPathsInCatalog = !_indexMultikeyPathsForRead.empty(); } // Since multikey metadata has changed, invalidate the query cache. @@ -396,7 +394,6 @@ void IndexCatalogEntryImpl::_catalogSetMultikey(OperationContext* opCtx, _isMultikeyForRead.store(true); if (_indexTracksMultikeyPathsInCatalog) { stdx::lock_guard<Latch> lk(_indexMultikeyPathsMutex); - _indexMultikeyPathsForRead = _indexMultikeyPathsForWrite; for (size_t i = 0; i < multikeyPaths.size(); ++i) { _indexMultikeyPathsForRead[i].insert(multikeyPaths[i].begin(), multikeyPaths[i].end()); } @@ -415,8 +412,6 @@ void IndexCatalogEntryImpl::_catalogSetMultikey(OperationContext* opCtx, // transaction successfully commits. Only after this point may a writer optimize out // flipping multikey. _isMultikeyForWrite.store(true); - stdx::lock_guard<Latch> lk(_indexMultikeyPathsMutex); - _indexMultikeyPathsForWrite = _indexMultikeyPathsForRead; }); } diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.h b/src/mongo/db/catalog/index_catalog_entry_impl.h index 13bd86209fe..6a6f84ff3aa 100644 --- a/src/mongo/db/catalog/index_catalog_entry_impl.h +++ b/src/mongo/db/catalog/index_catalog_entry_impl.h @@ -248,7 +248,7 @@ private: // this point, future writers do not need to update the catalog. mutable AtomicWord<bool> _isMultikeyForWrite; - // Controls concurrent access to '_indexMultikeyPathsForRead' and '_indexMultikeyPathsForWrite'. + // Controls concurrent access to '_indexMultikeyPathsForRead'. // We acquire this mutex rather than the RESOURCE_METADATA lock as a performance optimization // so that it is cheaper to detect whether there is actually any path-level multikey // information to update or not. @@ -263,8 +263,6 @@ private: // causes the index to be multikey. mutable MultikeyPaths _indexMultikeyPathsForRead; // May include paths not committed to catalog. - mutable MultikeyPaths - _indexMultikeyPathsForWrite; // Paths in catalog updated by a transaction commit. // The earliest snapshot that is allowed to read this index. boost::optional<Timestamp> _minVisibleSnapshot; |