summaryrefslogtreecommitdiff
path: root/src/mongo/db/repair_database.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-02-18 14:12:28 -0500
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-02-19 22:39:23 -0500
commit1894b1db527ee684120f433f5face7a8aa275dfb (patch)
tree5542e9508f3372e8319499012a5727e505718ce0 /src/mongo/db/repair_database.cpp
parent8d18f3593747f5ef5ca6f40cf37014de117e1c9d (diff)
downloadmongo-1894b1db527ee684120f433f5face7a8aa275dfb.tar.gz
SERVER-39653 During startup index recovery, ensure that dropping the index, opening the collection and initializing the index are all done in the same WriteUnitOfWork
Diffstat (limited to 'src/mongo/db/repair_database.cpp')
-rw-r--r--src/mongo/db/repair_database.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/mongo/db/repair_database.cpp b/src/mongo/db/repair_database.cpp
index 6256d0f3ca3..b1c6f99d06f 100644
--- a/src/mongo/db/repair_database.cpp
+++ b/src/mongo/db/repair_database.cpp
@@ -118,26 +118,20 @@ Status rebuildIndexesOnCollection(OperationContext* opCtx,
if (indexSpecs.empty())
return Status::OK();
- const auto& ns = cce->ns().ns();
- auto rs = dbce->getRecordStore(ns);
-
- // Open the collection.
- const auto uuid = cce->getCollectionOptions(opCtx).uuid;
- auto databaseHolder = DatabaseHolder::get(opCtx);
- std::unique_ptr<Collection> collection =
- databaseHolder->makeCollection(opCtx, ns, uuid, cce, rs, dbce);
-
// Rebuild the indexes provided by 'indexSpecs'.
IndexBuildsCoordinator* indexBuildsCoord = IndexBuildsCoordinator::get(opCtx);
UUID buildUUID = UUID::gen();
- auto swRebuild = indexBuildsCoord->startIndexRebuildForRecovery(
- opCtx, std::move(collection), indexSpecs, buildUUID);
+ auto swRebuild =
+ indexBuildsCoord->startIndexRebuildForRecovery(opCtx, dbce, cce, indexSpecs, buildUUID);
if (!swRebuild.isOK()) {
return swRebuild.getStatus();
}
auto[numRecords, dataSize] = swRebuild.getValue();
+ const auto& ns = cce->ns().ns();
+ auto rs = dbce->getRecordStore(ns);
+
// Update the record store stats after finishing and committing the index builds.
WriteUnitOfWork wuow(opCtx);
rs->updateStatsAfterRepair(opCtx, numRecords, dataSize);