summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-10-26 12:08:54 +0000
committerevergreen <evergreen@mongodb.com>2019-10-26 12:08:54 +0000
commitbb35ec679887e30101f69c71ebbd531635acb184 (patch)
tree4ba4659d3e915fddf3b556fc57eb8821996fbdfa
parent27b29ec51fecc0ebdd79e22fb688e662c99c8079 (diff)
downloadmongo-bb35ec679887e30101f69c71ebbd531635acb184.tar.gz
SERVER-44186 rename IndexBuildOptions::replSetAndNotPrimary to replSetAndNotPrimaryAtStart
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp16
-rw-r--r--src/mongo/db/index_builds_coordinator.h2
-rw-r--r--src/mongo/db/repl/oplog.cpp4
-rw-r--r--src/mongo/embedded/index_builds_coordinator_embedded.cpp2
4 files changed, 10 insertions, 14 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 411cc02c06f..0108d8a4b50 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -889,11 +889,6 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx,
const IndexBuildOptions& indexBuildOptions) {
const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID);
- // TODO(SERVER-39484): Since 'replSetAndNotPrimary' is derived from the replication state at the
- // start of the index build, this value is not resilient to member state changes like
- // stepup/stepdown.
- auto replSetAndNotPrimary = indexBuildOptions.replSetAndNotPrimary;
-
// This Status stays unchanged unless we catch an exception in the following try-catch block.
auto status = Status::OK();
try {
@@ -906,7 +901,7 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx,
boost::optional<Lock::CollectionLock> collLock;
collLock.emplace(opCtx, dbAndUUID, MODE_X);
- if (replSetAndNotPrimary) {
+ if (indexBuildOptions.replSetAndNotPrimaryAtStart) {
// This index build can only be interrupted at shutdown. For the duration of the
// OperationContext::runWithoutInterruptionExceptAtGlobalShutdown() invocation, any kill
// status set by the killOp command will be ignored. After
@@ -949,7 +944,7 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx,
// the next startup.
// On primary and standalone nodes, the failed index build will not be replicated so it is
// okay to propagate the shutdown error to the client.
- if (replSetAndNotPrimary) {
+ if (indexBuildOptions.replSetAndNotPrimaryAtStart) {
replState->stats.numIndexesAfter = replState->stats.numIndexesBefore;
status = Status::OK();
}
@@ -991,7 +986,7 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx,
Lock::DBLock dbLock(opCtx, nss.db(), MODE_IX);
- if (!replSetAndNotPrimary) {
+ if (!indexBuildOptions.replSetAndNotPrimaryAtStart) {
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
if (replCoord->getSettings().usingReplSets() &&
replCoord->canAcceptWritesFor(opCtx, nss)) {
@@ -1040,7 +1035,7 @@ void IndexBuildsCoordinator::_runIndexBuildInner(OperationContext* opCtx,
// Failed index builds should abort secondary oplog application, except when the index build
// was stopped due to processing an abortIndexBuild oplog entry.
- if (replSetAndNotPrimary) {
+ if (indexBuildOptions.replSetAndNotPrimaryAtStart) {
if (status == ErrorCodes::IndexBuildAborted) {
return;
}
@@ -1143,7 +1138,7 @@ void IndexBuildsCoordinator::_buildIndex(
}
Timestamp commitIndexBuildTimestamp;
- if (supportsTwoPhaseIndexBuild() && indexBuildOptions.replSetAndNotPrimary &&
+ if (supportsTwoPhaseIndexBuild() && indexBuildOptions.replSetAndNotPrimaryAtStart &&
IndexBuildProtocol::kTwoPhase == replState->protocol) {
log() << "Index build waiting for commit or abort before completing final phase: "
@@ -1232,6 +1227,7 @@ void IndexBuildsCoordinator::_buildIndex(
if (supportsTwoPhaseIndexBuild()) {
return;
}
+
opObserver->onCreateIndex(
opCtx, collection->ns(), replState->collectionUUID, spec, fromMigrate);
};
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index 7f582b0c684..47612b6dfd3 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -74,7 +74,7 @@ public:
*/
struct IndexBuildOptions {
boost::optional<CommitQuorumOptions> commitQuorum;
- bool replSetAndNotPrimary = false;
+ bool replSetAndNotPrimaryAtStart = false;
};
/**
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 32e4c01fef2..9597cce919f 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -188,7 +188,7 @@ Status startIndexBuild(OperationContext* opCtx,
IndexBuildsCoordinator::IndexBuildOptions indexBuildOptions;
invariant(!indexBuildOptions.commitQuorum);
- indexBuildOptions.replSetAndNotPrimary = true;
+ indexBuildOptions.replSetAndNotPrimaryAtStart = true;
// We don't pass in a commit quorum here because secondary nodes don't have any knowledge of it.
return IndexBuildsCoordinator::get(opCtx)
@@ -278,7 +278,7 @@ void createIndexForApplyOps(OperationContext* opCtx,
// it.
IndexBuildsCoordinator::IndexBuildOptions indexBuildOptions;
invariant(!indexBuildOptions.commitQuorum);
- indexBuildOptions.replSetAndNotPrimary = true;
+ indexBuildOptions.replSetAndNotPrimaryAtStart = true;
// This spawns a new thread and returns immediately.
MONGO_COMPILER_VARIABLE_UNUSED auto fut = uassertStatusOK(
diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.cpp b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
index 9c5ebfe7b4a..5eea1095d0c 100644
--- a/src/mongo/embedded/index_builds_coordinator_embedded.cpp
+++ b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
@@ -70,7 +70,7 @@ IndexBuildsCoordinatorEmbedded::startIndexBuild(OperationContext* opCtx,
auto replState = invariant(_getIndexBuild(buildUUID));
- invariant(!indexBuildOptions.replSetAndNotPrimary);
+ invariant(!indexBuildOptions.replSetAndNotPrimaryAtStart);
_runIndexBuild(opCtx, buildUUID, indexBuildOptions);
return replState->sharedPromise.getFuture();