summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-10-08 16:49:50 +0000
committerevergreen <evergreen@mongodb.com>2019-10-08 16:49:50 +0000
commit265bdc7e2358eac75cc61943d97c8cb6860e667c (patch)
tree77baa1056ca6a75a8969c920f26f8bb85469b300 /src
parent22256673a9db8f9cf44bdb149fe20a599ecb7e9a (diff)
downloadmongo-265bdc7e2358eac75cc61943d97c8cb6860e667c.tar.gz
SERVER-39002 IndexBuildsManager::tearDownIndexBuild() accepts MultiIndexBuild::OnCleanUpFn
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/index_builds_manager.cpp5
-rw-r--r--src/mongo/db/catalog/index_builds_manager.h6
-rw-r--r--src/mongo/db/catalog/index_builds_manager_test.cpp6
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp12
4 files changed, 20 insertions, 9 deletions
diff --git a/src/mongo/db/catalog/index_builds_manager.cpp b/src/mongo/db/catalog/index_builds_manager.cpp
index 7f6711e8ba0..ee6112a0569 100644
--- a/src/mongo/db/catalog/index_builds_manager.cpp
+++ b/src/mongo/db/catalog/index_builds_manager.cpp
@@ -288,10 +288,11 @@ bool IndexBuildsManager::interruptIndexBuild(OperationContext* opCtx,
void IndexBuildsManager::tearDownIndexBuild(OperationContext* opCtx,
Collection* collection,
- const UUID& buildUUID) {
+ const UUID& buildUUID,
+ OnCleanUpFn onCleanUpFn) {
// TODO verify that the index builder is in a finished state before allowing its destruction.
auto builder = _getBuilder(buildUUID);
- builder->cleanUpAfterBuild(opCtx, collection, MultiIndexBlock::kNoopOnCleanUpFn);
+ builder->cleanUpAfterBuild(opCtx, collection, onCleanUpFn);
_unregisterIndexBuild(buildUUID);
}
diff --git a/src/mongo/db/catalog/index_builds_manager.h b/src/mongo/db/catalog/index_builds_manager.h
index 55f2fe73211..f686efd38c0 100644
--- a/src/mongo/db/catalog/index_builds_manager.h
+++ b/src/mongo/db/catalog/index_builds_manager.h
@@ -175,7 +175,11 @@ public:
/**
* Cleans up the index build state and unregisters it from the manager.
*/
- void tearDownIndexBuild(OperationContext* opCtx, Collection* collection, const UUID& buildUUID);
+ using OnCleanUpFn = MultiIndexBlock::OnCleanUpFn;
+ void tearDownIndexBuild(OperationContext* opCtx,
+ Collection* collection,
+ const UUID& buildUUID,
+ OnCleanUpFn onCleanUpFn);
/**
* Returns true if the index build supports background writes while building an index. This is
diff --git a/src/mongo/db/catalog/index_builds_manager_test.cpp b/src/mongo/db/catalog/index_builds_manager_test.cpp
index 3ca43d04039..34f1e26d212 100644
--- a/src/mongo/db/catalog/index_builds_manager_test.cpp
+++ b/src/mongo/db/catalog/index_builds_manager_test.cpp
@@ -91,8 +91,10 @@ TEST_F(IndexBuildsManagerTest, IndexBuildsManagerSetUpAndTearDown) {
_buildUUID,
MultiIndexBlock::kNoopOnInitFn));
- _indexBuildsManager.tearDownIndexBuild(
- operationContext(), autoColl.getCollection(), _buildUUID);
+ _indexBuildsManager.tearDownIndexBuild(operationContext(),
+ autoColl.getCollection(),
+ _buildUUID,
+ MultiIndexBlock::kNoopOnCleanUpFn);
}
} // namespace
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 760043ad70f..3b429dd73e3 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -712,7 +712,8 @@ IndexBuildsCoordinator::_registerAndSetUpIndexBuild(
return boost::none;
}
- _indexBuildsManager.tearDownIndexBuild(opCtx, collection, replIndexBuildState->buildUUID);
+ _indexBuildsManager.tearDownIndexBuild(
+ opCtx, collection, replIndexBuildState->buildUUID, MultiIndexBlock::kNoopOnCleanUpFn);
// Unregister the index build before setting the promise, so callers do not see the build again.
_unregisterIndexBuild(lk, replIndexBuildState);
@@ -906,9 +907,11 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx,
Lock::CollectionLock collLock(opCtx, nss, MODE_X);
- _indexBuildsManager.tearDownIndexBuild(opCtx, collection, replState->buildUUID);
+ _indexBuildsManager.tearDownIndexBuild(
+ opCtx, collection, replState->buildUUID, MultiIndexBlock::kNoopOnCleanUpFn);
} else {
- _indexBuildsManager.tearDownIndexBuild(opCtx, collection, replState->buildUUID);
+ _indexBuildsManager.tearDownIndexBuild(
+ opCtx, collection, replState->buildUUID, MultiIndexBlock::kNoopOnCleanUpFn);
}
}
@@ -1184,7 +1187,8 @@ StatusWith<std::pair<long long, long long>> IndexBuildsCoordinator::_runIndexReb
if (status.isOK()) {
// A successful index build means that all the requested indexes are now part of the
// catalog.
- _indexBuildsManager.tearDownIndexBuild(opCtx, collection, buildUUID);
+ _indexBuildsManager.tearDownIndexBuild(
+ opCtx, collection, buildUUID, MultiIndexBlock::kNoopOnCleanUpFn);
} else {
// An index build failure during recovery is fatal.
logFailure(status, nss, replState);