diff options
author | Benety Goh <benety@mongodb.com> | 2019-10-19 01:14:01 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-19 01:14:01 +0000 |
commit | 4f17a096fa79d3a37a7ede167f38fd3fbc56b209 (patch) | |
tree | 65b29db6f15e4d575e25a6ef119cb4a336ba932b | |
parent | e2588753f53e537132539ea10a6588f4055caa40 (diff) | |
download | mongo-4f17a096fa79d3a37a7ede167f38fd3fbc56b209.tar.gz |
SERVER-39484 IndexBuildsCoordinator unblocks index builds on stepup
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index 295df777f6e..02460d37d7f 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -425,7 +425,18 @@ void IndexBuildsCoordinator::onStepUp(OperationContext* opCtx) { log() << "IndexBuildsCoordinator::onStepUp - this node is stepping up to primary"; auto indexBuilds = _getIndexBuilds(); - auto onIndexBuild = [](std::shared_ptr<ReplIndexBuildState> replState) {}; + auto onIndexBuild = [](std::shared_ptr<ReplIndexBuildState> replState) { + stdx::unique_lock<Latch> lk(replState->mutex); + if (!replState->aborted) { + // Leave commit timestamp as null. We will be writing a commitIndexBuild oplog entry now + // that we are primary and using the timestamp from the oplog entry to update the mdb + // catalog. + invariant(replState->commitTimestamp.isNull(), replState->buildUUID.toString()); + invariant(!replState->isCommitReady, replState->buildUUID.toString()); + replState->isCommitReady = true; + replState->condVar.notify_all(); + } + }; forEachIndexBuild(indexBuilds, "IndexBuildsCoordinator::onStepUp - "_sd, onIndexBuild); } |