From 50b2da21b8809375b214b085abc0e0d164da4215 Mon Sep 17 00:00:00 2001 From: Xiangyu Yao Date: Mon, 3 Jun 2019 17:05:21 -0400 Subject: SERVER-41478 Take initialization of index catalog out of collection constructor --- src/mongo/db/catalog/collection_impl.cpp | 3 --- src/mongo/db/catalog/database_impl.cpp | 8 ++++++++ src/mongo/db/index_builds_coordinator.cpp | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/mongo') diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp index 47bb4d226d0..d9cdc0a57dd 100644 --- a/src/mongo/db/catalog/collection_impl.cpp +++ b/src/mongo/db/catalog/collection_impl.cpp @@ -215,11 +215,8 @@ CollectionImpl::CollectionImpl(OperationContext* opCtx, _cappedNotifier(_recordStore->isCapped() ? stdx::make_unique() : nullptr) { - _indexCatalog->init(opCtx).transitional_ignore(); if (isCapped()) _recordStore->setCappedCallback(this); - - _infoCache->init(opCtx); } CollectionImpl::~CollectionImpl() { diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index 57bc52bfc50..78067c9a48b 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -178,6 +178,12 @@ void DatabaseImpl::init(OperationContext* const opCtx) const { catalog.registerCollectionObject(uuid, std::move(ownedCollection)); } + for (const auto& uuid : catalog.getAllCollectionUUIDsFromDb(_name)) { + auto collection = catalog.lookupCollectionByUUID(uuid); + collection->getIndexCatalog()->init(opCtx).transitional_ignore(); + collection->infoCache()->init(opCtx); + } + // At construction time of the viewCatalog, the CollectionCatalog map wasn't initialized yet, // so no system.views collection would be found. Now we're sufficiently initialized, signal a // version change. Also force a reload, so if there are problems with the catalog contents as @@ -689,6 +695,8 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx, // Create Collection object auto& catalog = CollectionCatalog::get(opCtx); auto ownedCollection = _createCollectionInstance(opCtx, nss); + ownedCollection->getIndexCatalog()->init(opCtx).transitional_ignore(); + ownedCollection->infoCache()->init(opCtx); Collection* collection = ownedCollection.get(); catalog.onCreateCollection(opCtx, std::move(ownedCollection), *(collection->uuid())); opCtx->recoveryUnit()->onCommit([collection](auto commitTime) { diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index b4fcc46e629..dc556ad7e81 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -200,6 +200,8 @@ StatusWith> IndexBuildsCoordinator::startIndexRe const auto uuid = cce->getCollectionOptions(opCtx).uuid; auto databaseHolder = DatabaseHolder::get(opCtx); collection = databaseHolder->makeCollection(opCtx, ns, uuid, cce, rs); + collection->getIndexCatalog()->init(opCtx).transitional_ignore(); + collection->infoCache()->init(opCtx); // Register the index build. During recovery, collections may not have UUIDs present yet to // due upgrading. We don't require collection UUIDs during recovery except to create a -- cgit v1.2.1