summaryrefslogtreecommitdiff
path: root/src/mongo/db/rebuild_indexes.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2021-05-11 14:30:26 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-20 19:18:53 +0000
commit11de948b0c50df7d12de09ae0f01e791fc5d70d7 (patch)
tree5a5a89cce0dc94f21778725184f8da3d5f76a13b /src/mongo/db/rebuild_indexes.cpp
parentb2802257c7cd2cf253847d67da5ddcc780a5b85f (diff)
downloadmongo-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/rebuild_indexes.cpp')
-rw-r--r--src/mongo/db/rebuild_indexes.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/mongo/db/rebuild_indexes.cpp b/src/mongo/db/rebuild_indexes.cpp
index 52962679162..c2986396d6a 100644
--- a/src/mongo/db/rebuild_indexes.cpp
+++ b/src/mongo/db/rebuild_indexes.cpp
@@ -40,20 +40,17 @@
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/index_builds_coordinator.h"
-#include "mongo/db/storage/durable_catalog.h"
namespace mongo {
-StatusWith<IndexNameObjs> getIndexNameObjs(OperationContext* opCtx,
- RecordId catalogId,
+StatusWith<IndexNameObjs> getIndexNameObjs(const CollectionPtr& collection,
std::function<bool(const std::string&)> filter) {
IndexNameObjs ret;
std::vector<std::string>& indexNames = ret.first;
std::vector<BSONObj>& indexSpecs = ret.second;
- auto durableCatalog = DurableCatalog::get(opCtx);
{
// Fetch all indexes
- durableCatalog->getAllIndexes(opCtx, catalogId, &indexNames);
+ collection->getAllIndexes(&indexNames);
auto newEnd =
std::remove_if(indexNames.begin(),
indexNames.end(),
@@ -64,7 +61,7 @@ StatusWith<IndexNameObjs> getIndexNameObjs(OperationContext* opCtx,
for (const auto& name : indexNames) {
- BSONObj spec = durableCatalog->getIndexSpec(opCtx, catalogId, name);
+ BSONObj spec = collection->getIndexSpec(name);
using IndexVersion = IndexDescriptor::IndexVersion;
IndexVersion indexVersion = IndexVersion::kV1;
if (auto indexVersionElem = spec[IndexDescriptor::kIndexVersionFieldName]) {