summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Larkin-York <dan.larkin-york@mongodb.com>2022-01-21 22:56:53 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-21 23:22:14 +0000
commit212a8dbb47f07427dae194a9c75baec1d81d9259 (patch)
treecc892738369efd303b9a91613166b746912335aa
parent8643180253568239b1e53cfb345453a4fbdbfd8f (diff)
downloadmongo-r5.0.6.tar.gz
SERVER-62618 Avoid quadratic behavior at startup with many collectionsr5.0.6-rc2r5.0.6
-rw-r--r--src/mongo/db/storage/kv/storage_engine_test.cpp10
-rw-r--r--src/mongo/db/storage/storage_engine_impl.cpp1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/db/storage/kv/storage_engine_test.cpp b/src/mongo/db/storage/kv/storage_engine_test.cpp
index 6d64c063ee7..59420db140a 100644
--- a/src/mongo/db/storage/kv/storage_engine_test.cpp
+++ b/src/mongo/db/storage/kv/storage_engine_test.cpp
@@ -389,7 +389,10 @@ TEST_F(StorageEngineRepairTest, LoadCatalogRecoversOrphansInCatalog) {
ASSERT(!collectionExists(opCtx.get(), collNs));
// When in a repair context, loadCatalog() recreates catalog entries for orphaned idents.
- _storageEngine->loadCatalog(opCtx.get(), StorageEngine::LastShutdownState::kClean);
+ {
+ Lock::GlobalWrite writeLock(opCtx.get(), Date_t::max(), Lock::InterruptBehavior::kThrow);
+ _storageEngine->loadCatalog(opCtx.get(), StorageEngine::LastShutdownState::kClean);
+ }
auto identNs = swCollInfo.getValue().ident;
std::replace(identNs.begin(), identNs.end(), '-', '_');
NamespaceString orphanNs = NamespaceString("local.orphan." + identNs);
@@ -422,7 +425,10 @@ TEST_F(StorageEngineTest, LoadCatalogDropsOrphans) {
// When in a normal startup context, loadCatalog() does not recreate catalog entries for
// orphaned idents.
- _storageEngine->loadCatalog(opCtx.get(), StorageEngine::LastShutdownState::kClean);
+ {
+ Lock::GlobalWrite writeLock(opCtx.get(), Date_t::max(), Lock::InterruptBehavior::kThrow);
+ _storageEngine->loadCatalog(opCtx.get(), StorageEngine::LastShutdownState::kClean);
+ }
// reconcileCatalogAndIdents() drops orphaned idents.
auto reconcileResult = unittest::assertGet(reconcile(opCtx.get()));
ASSERT_EQUALS(0UL, reconcileResult.indexesToRebuild.size());
diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp
index e3b397337cd..6af5185e793 100644
--- a/src/mongo/db/storage/storage_engine_impl.cpp
+++ b/src/mongo/db/storage/storage_engine_impl.cpp
@@ -236,6 +236,7 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
}
}
+ BatchedCollectionCatalogWriter catalogBatchWriter{opCtx};
for (DurableCatalog::Entry entry : catalogEntries) {
if (loadingFromUncleanShutdownOrRepair) {
// If we are loading the catalog after an unclean shutdown or during repair, it's