summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/catalog_control.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2019-11-14 00:39:57 +0000
committerevergreen <evergreen@mongodb.com>2019-11-14 00:39:57 +0000
commit103318868c860e441050652b6dae137d0d21d593 (patch)
tree7f745ad6296c6ff8ce8c1901930eec81368ca297 /src/mongo/db/catalog/catalog_control.cpp
parent1a3566fc89ed8637cfabb3b5436cde58731df759 (diff)
downloadmongo-103318868c860e441050652b6dae137d0d21d593.tar.gz
SERVER-39451 Support recover-to-stable rollback for two-phase index builds
Diffstat (limited to 'src/mongo/db/catalog/catalog_control.cpp')
-rw-r--r--src/mongo/db/catalog/catalog_control.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp
index 916deb9f2c7..bbcea9f741c 100644
--- a/src/mongo/db/catalog/catalog_control.cpp
+++ b/src/mongo/db/catalog/catalog_control.cpp
@@ -110,13 +110,12 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib
storageEngine->loadCatalog(opCtx);
log() << "openCatalog: reconciling catalog and idents";
- auto indexesToRebuild = storageEngine->reconcileCatalogAndIdents(opCtx);
- fassert(40688, indexesToRebuild.getStatus());
+ auto reconcileResult = fassert(40688, storageEngine->reconcileCatalogAndIdents(opCtx));
// Determine which indexes need to be rebuilt. rebuildIndexesOnCollection() requires that all
// indexes on that collection are done at once, so we use a map to group them together.
StringMap<IndexNameObjs> nsToIndexNameObjMap;
- for (StorageEngine::IndexIdentifier indexIdentifier : indexesToRebuild.getValue()) {
+ for (StorageEngine::IndexIdentifier indexIdentifier : reconcileResult.indexesToRebuild) {
auto indexName = indexIdentifier.indexName;
auto indexSpecs =
getIndexNameObjs(opCtx,
@@ -158,6 +157,13 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib
fassert(40690, rebuildIndexesOnCollection(opCtx, collection, indexSpecs));
}
+ // Once all unfinished index builds have been dropped and the catalog has been reloaded, restart
+ // any unfinished index builds. This will not restart any index builds to completion, but rather
+ // start the background thread, build the index, and wait for a replicated commit or abort oplog
+ // entry.
+ IndexBuildsCoordinator::get(opCtx)->restartIndexBuildsForRecovery(
+ opCtx, reconcileResult.indexBuildsToRestart);
+
// Open all databases and repopulate the CollectionCatalog.
log() << "openCatalog: reopening all databases";
auto databaseHolder = DatabaseHolder::get(opCtx);
@@ -187,6 +193,7 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib
}
}
}
+
// Opening CollectionCatalog: The collection catalog is now in sync with the storage engine
// catalog. Clear the pre-closing state.
CollectionCatalog::get(opCtx).onOpenCatalog(opCtx);