summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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