summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiangyu Yao <xiangyu.yao@mongodb.com>2019-06-03 17:05:21 -0400
committerXiangyu Yao <xiangyu.yao@mongodb.com>2019-06-19 13:57:29 -0400
commit74a00f752e259816232a6b9667453d5bcd7d10ba (patch)
treee9e2456d92ea5ffb429399a712a43c94909c02d4
parenta7e5069c5a5caae4d64efa9086b0c5f0766ab508 (diff)
downloadmongo-74a00f752e259816232a6b9667453d5bcd7d10ba.tar.gz
SERVER-41478 Take initialization of index catalog out of collection constructor
(cherry picked from commit 50b2da21b8809375b214b085abc0e0d164da4215)
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp3
-rw-r--r--src/mongo/db/catalog/database_impl.cpp8
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp2
3 files changed, 10 insertions, 3 deletions
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<CappedInsertNotifier>()
: 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 c76caee6c01..57b3bcb1780 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -200,6 +200,8 @@ StatusWith<std::pair<long long, long long>> 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