summaryrefslogtreecommitdiff
path: root/src/mongo/db/startup_recovery.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2022-04-07 12:59:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-07 14:15:32 +0000
commit3567535c340e69feeadbb0866f8019a6d84e355c (patch)
tree65bee7d35dbdd65ced53678cef518cc0b086d843 /src/mongo/db/startup_recovery.cpp
parent48f3e1ffc2f89353bb4772f10f92b1ec33bc0829 (diff)
downloadmongo-3567535c340e69feeadbb0866f8019a6d84e355c.tar.gz
SERVER-65313 Use BatchedCollectionCatalogWriter during startup recovery
This allows writable Collections to be requested any time during startup recovery without being in an active WUOW.
Diffstat (limited to 'src/mongo/db/startup_recovery.cpp')
-rw-r--r--src/mongo/db/startup_recovery.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mongo/db/startup_recovery.cpp b/src/mongo/db/startup_recovery.cpp
index 00a65cc7773..ca1b6fb94e0 100644
--- a/src/mongo/db/startup_recovery.cpp
+++ b/src/mongo/db/startup_recovery.cpp
@@ -469,11 +469,7 @@ void startupRepair(OperationContext* opCtx, StorageEngine* storageEngine) {
ScopeGuard abortRepairOnFCVErrors(
[&] { StorageRepairObserver::get(opCtx->getServiceContext())->onRepairDone(opCtx); });
- // Use the BatchedCollectionCatalogWriter so all Collection writes to the in-memory catalog are
- // done in a single copy-on-write of the catalog. This avoids quadratic behavior where we
- // iterate over every collection and perform writes where the catalog would be copied every
- // time.
- BatchedCollectionCatalogWriter catalog(opCtx);
+ auto catalog = CollectionCatalog::get(opCtx);
if (auto fcvColl = catalog->lookupCollectionByNamespace(
opCtx, NamespaceString::kServerConfigurationNamespace)) {
auto databaseHolder = DatabaseHolder::get(opCtx);
@@ -619,6 +615,12 @@ void repairAndRecoverDatabases(OperationContext* opCtx,
auto const storageEngine = opCtx->getServiceContext()->getStorageEngine();
Lock::GlobalWrite lk(opCtx);
+ // Use the BatchedCollectionCatalogWriter so all Collection writes to the in-memory catalog are
+ // done in a single copy-on-write of the catalog. This avoids quadratic behavior where we
+ // iterate over every collection and perform writes where the catalog would be copied every
+ // time.
+ BatchedCollectionCatalogWriter catalog(opCtx);
+
// Create the FCV document for the first time, if necessary. Replica set nodes only initialize
// the FCV when the replica set is first initiated or by data replication.
const bool usingReplication = repl::ReplicationCoordinator::get(opCtx)->isReplEnabled();