summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-04-23 05:59:14 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-05 01:53:50 +0000
commitc746480883a9bef1d6eb43149df9ec3a51cf1c12 (patch)
treef3dbdb35427809722a36df9a22defb39bdc93714
parentda18d99f15a19713af4035a5d2a6ef4e7caab46d (diff)
downloadmongo-c746480883a9bef1d6eb43149df9ec3a51cf1c12.tar.gz
SERVER-47439 build system indexes single-phased
(cherry picked from commit 906e1a72f98d42106c02914bf9cc1dd3101483ac)
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp38
1 files changed, 1 insertions, 37 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 313f2725a71..d7d99ebf2c7 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -1387,45 +1387,9 @@ void IndexBuildsCoordinator::createIndexes(OperationContext* opCtx,
auto opObserver = opCtx->getServiceContext()->getOpObserver();
auto onCreateEachFn = [&](const BSONObj& spec) {
- // If two phase index builds is enabled, index build will be coordinated using
- // startIndexBuild and commitIndexBuild oplog entries.
- if (supportsTwoPhaseIndexBuild()) {
- return;
- }
opObserver->onCreateIndex(opCtx, collection->ns(), collectionUUID, spec, fromMigrate);
};
- auto onCommitFn = [&] {
- // Index build completion will be timestamped using the createIndexes oplog entry.
- if (!supportsTwoPhaseIndexBuild()) {
- return;
- }
-
- auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- if (!(replCoord->getSettings().usingReplSets() &&
- replCoord->canAcceptWritesFor(opCtx, nss))) {
- // Not primary.
- return;
- }
-
- // TODO SERVER-47439: Should remove this onCommitFn lambda function as we no longer
- // need to generate startIndexBuild and commitIndexBuild oplog entries.
-
-
- // Currently, primary doesn't wait for any votes from secondaries to commit
- // the index build. So, it's of no use to set the commit quorum option of any value
- // greater than 0. Disabling commit quorum is just an optimization to avoid secondaries
- // from trying to vote before committing index build.
- //
- // Persist the commit quorum value in the config.system.indexBuilds collection.
- IndexBuildEntry indexbuildEntry(buildUUID,
- collectionUUID,
- CommitQuorumOptions(CommitQuorumOptions::kDisabled),
- extractIndexNames(specs));
- uassertStatusOK(addIndexBuildEntry(opCtx, indexbuildEntry));
-
- opObserver->onStartIndexBuild(opCtx, nss, collectionUUID, buildUUID, specs, fromMigrate);
- opObserver->onCommitIndexBuild(opCtx, nss, collectionUUID, buildUUID, specs, fromMigrate);
- };
+ auto onCommitFn = MultiIndexBlock::kNoopOnCommitFn;
uassertStatusOK(_indexBuildsManager.commitIndexBuild(
opCtx, collection, nss, buildUUID, onCreateEachFn, onCommitFn));
abortOnExit.dismiss();