summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-06-04 20:39:46 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-05 01:02:40 +0000
commit4042389f588d64e9537253d7879450f3db5efcb1 (patch)
treecf4fbce62aee59e1b255eb9a7ed53cea4d7eff0e
parent7ad1bc37609f084f7eca25045f6ac6fe87a0a8fc (diff)
downloadmongo-4042389f588d64e9537253d7879450f3db5efcb1.tar.gz
SERVER-47182 remove IndexBuildsCoordinator::IndexBuildOptions::replSetAndNotPrimaryAtStart
This option is only applicable to single-phase index builds on secondaries, which no longer go through the IndexBuildsCoordinator.
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp35
-rw-r--r--src/mongo/db/index_builds_coordinator.h1
-rw-r--r--src/mongo/embedded/index_builds_coordinator_embedded.cpp1
3 files changed, 2 insertions, 35 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index bc52dc79b21..3d4869d512c 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -654,7 +654,6 @@ void IndexBuildsCoordinator::applyStartIndexBuild(OperationContext* opCtx,
const auto nss = getNsFromUUID(opCtx, collUUID);
IndexBuildsCoordinator::IndexBuildOptions indexBuildOptions;
- indexBuildOptions.replSetAndNotPrimaryAtStart = true;
indexBuildOptions.applicationMode = applicationMode;
// If this is an initial syncing node, drop any conflicting ready index specs prior to
@@ -1311,8 +1310,6 @@ void IndexBuildsCoordinator::restartIndexBuildsForRecovery(OperationContext* opC
"collectionUUID"_attr = build.collUUID,
"buildUUID"_attr = buildUUID);
IndexBuildsCoordinator::IndexBuildOptions indexBuildOptions;
- // Start the index build as if in secondary oplog application.
- indexBuildOptions.replSetAndNotPrimaryAtStart = true;
// Indicate that the initialization should not generate oplog entries or timestamps for the
// first catalog write, and that the original durable catalog entries should be dropped and
// replaced.
@@ -1994,15 +1991,6 @@ void IndexBuildsCoordinator::_cleanUpSinglePhaseAfterFailure(
return;
}
- if (indexBuildOptions.replSetAndNotPrimaryAtStart) {
- // This build started and failed as a secondary. Single-phase index builds started on
- // secondaries may not fail. Do not clean up the index build. It must remain unfinished
- // until it is successfully rebuilt on startup.
- fassert(31354,
- status.withContext(str::stream() << "Index build: " << replState->buildUUID
- << "; Database: " << replState->dbName));
- }
-
// The index builder thread can abort on its own if it is interrupted by a user killop. This
// would prevent us from taking locks. Use a new OperationContext to abort the index build.
runOnAlternateContext(
@@ -2315,8 +2303,7 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide
// If we are no longer primary and a single phase index build started as primary attempts to
// commit, trigger a self-abort.
- if (!isMaster && IndexBuildAction::kSinglePhaseCommit == action &&
- !indexBuildOptions.replSetAndNotPrimaryAtStart) {
+ if (!isMaster && IndexBuildAction::kSinglePhaseCommit == action) {
uassertStatusOK(
{ErrorCodes::NotMaster,
str::stream() << "Unable to commit index build because we are no longer primary: "
@@ -2363,10 +2350,7 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide
// IndexBuildAborted error code.
const bool twoPhaseAndNotPrimary =
IndexBuildProtocol::kTwoPhase == replState->protocol && !isMaster;
- const bool singlePhaseAndNotPrimaryAtStart =
- IndexBuildProtocol::kSinglePhase == replState->protocol &&
- indexBuildOptions.replSetAndNotPrimaryAtStart;
- if (twoPhaseAndNotPrimary || singlePhaseAndNotPrimaryAtStart) {
+ if (twoPhaseAndNotPrimary) {
LOGV2_FATAL(4698902,
"Index build failed while not primary",
"buildUUID"_attr = replState->buildUUID,
@@ -2390,21 +2374,6 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide
return;
}
- if (indexBuildOptions.replSetAndNotPrimaryAtStart) {
- LOGV2_DEBUG(20671,
- 1,
- "Skipping createIndexes oplog entry for index build: {replState_buildUUID}",
- "replState_buildUUID"_attr = replState->buildUUID);
- // Get a timestamp to complete the index build in the absence of a createIndexBuild
- // oplog entry.
- repl::UnreplicatedWritesBlock uwb(opCtx);
- if (!IndexTimestampHelper::setGhostCommitTimestampForCatalogWrite(opCtx,
- collection->ns())) {
- LOGV2(20672, "Did not timestamp index commit write");
- }
- return;
- }
-
auto opObserver = opCtx->getServiceContext()->getOpObserver();
auto fromMigrate = false;
opObserver->onCreateIndex(
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index e79bc10eb36..9eada1eba38 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -86,7 +86,6 @@ public:
*/
struct IndexBuildOptions {
boost::optional<CommitQuorumOptions> commitQuorum;
- bool replSetAndNotPrimaryAtStart = false;
ApplicationMode applicationMode = ApplicationMode::kNormal;
};
diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.cpp b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
index e32b7ffce97..b4d3fe88450 100644
--- a/src/mongo/embedded/index_builds_coordinator_embedded.cpp
+++ b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
@@ -69,7 +69,6 @@ IndexBuildsCoordinatorEmbedded::startIndexBuild(OperationContext* opCtx,
if (!status.isOK()) {
return status;
}
- invariant(!indexBuildOptions.replSetAndNotPrimaryAtStart);
_runIndexBuild(opCtx, buildUUID, indexBuildOptions);
auto replState = invariant(_getIndexBuild(buildUUID));