summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
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
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')
-rw-r--r--src/mongo/db/catalog/catalog_control.cpp13
-rw-r--r--src/mongo/db/catalog/catalog_control_test.cpp4
-rw-r--r--src/mongo/db/catalog/index_builds_manager.cpp9
-rw-r--r--src/mongo/db/catalog/index_builds_manager.h1
4 files changed, 14 insertions, 13 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);
diff --git a/src/mongo/db/catalog/catalog_control_test.cpp b/src/mongo/db/catalog/catalog_control_test.cpp
index 21740aa1b12..d2527e7efb9 100644
--- a/src/mongo/db/catalog/catalog_control_test.cpp
+++ b/src/mongo/db/catalog/catalog_control_test.cpp
@@ -148,9 +148,9 @@ public:
}
void setCachePressureForTest(int pressure) final {}
void triggerJournalFlush() const final {}
- StatusWith<std::vector<IndexIdentifier>> reconcileCatalogAndIdents(
+ StatusWith<StorageEngine::ReconcileResult> reconcileCatalogAndIdents(
OperationContext* opCtx) final {
- return std::vector<IndexIdentifier>();
+ return ReconcileResult{};
}
Timestamp getAllDurableTimestamp() const final {
return {};
diff --git a/src/mongo/db/catalog/index_builds_manager.cpp b/src/mongo/db/catalog/index_builds_manager.cpp
index 952fb1c05b9..0c85b725664 100644
--- a/src/mongo/db/catalog/index_builds_manager.cpp
+++ b/src/mongo/db/catalog/index_builds_manager.cpp
@@ -109,13 +109,8 @@ Status IndexBuildsManager::setUpIndexBuild(OperationContext* opCtx,
return ex.toStatus();
}
- if (options.forRecovery) {
- log() << "Index build initialized: " << buildUUID << ": " << nss
- << ": indexes: " << indexes.size();
- } else {
- log() << "Index build initialized: " << buildUUID << ": " << nss << " ("
- << collection->uuid() << " ): indexes: " << indexes.size();
- }
+ log() << "Index build initialized: " << buildUUID << ": " << nss << " (" << collection->uuid()
+ << " ): indexes: " << indexes.size();
return Status::OK();
}
diff --git a/src/mongo/db/catalog/index_builds_manager.h b/src/mongo/db/catalog/index_builds_manager.h
index 1843177d5ae..c16b5b57af4 100644
--- a/src/mongo/db/catalog/index_builds_manager.h
+++ b/src/mongo/db/catalog/index_builds_manager.h
@@ -69,7 +69,6 @@ public:
SetupOptions();
IndexConstraints indexConstraints = IndexConstraints::kEnforce;
IndexBuildProtocol protocol = IndexBuildProtocol::kSinglePhase;
- bool forRecovery = false;
};
IndexBuildsManager() = default;