summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2020-03-03 01:38:37 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-03 23:55:58 +0000
commitcde28e2ab957bd4a27ef240dfbfeea3cc8a70b74 (patch)
tree3d8b2f3eb8c6e3f5e0193b0138293757a8120bee /src/mongo
parent4258a3d30c35bbdb1506002557a7ff1e98aef490 (diff)
downloadmongo-cde28e2ab957bd4a27ef240dfbfeea3cc8a70b74.tar.gz
SERVER-45001 Enable commit quorum for two phase index builds by default.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/validate_state_test.cpp27
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp2
-rw-r--r--src/mongo/db/index_builds_coordinator.h5
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod.cpp4
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod.h3
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod_test.cpp7
-rw-r--r--src/mongo/db/storage/two_phase_index_build_knobs.idl2
-rw-r--r--src/mongo/dbtests/storage_timestamp_tests.cpp13
-rw-r--r--src/mongo/embedded/index_builds_coordinator_embedded.cpp2
-rw-r--r--src/mongo/embedded/index_builds_coordinator_embedded.h3
10 files changed, 59 insertions, 9 deletions
diff --git a/src/mongo/db/catalog/validate_state_test.cpp b/src/mongo/db/catalog/validate_state_test.cpp
index 5742e0f782f..2f0d36029e6 100644
--- a/src/mongo/db/catalog/validate_state_test.cpp
+++ b/src/mongo/db/catalog/validate_state_test.cpp
@@ -144,6 +144,12 @@ TEST_F(ValidateStateTest, UncheckpointedCollectionShouldThrowCursorNotFoundError
// Basic test with {background:false} to open cursors against all collection indexes.
TEST_F(ValidateStateTest, OpenCursorsOnAllIndexes) {
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
auto opCtx = operationContext();
createCollectionAndPopulateIt(opCtx, kNss);
@@ -187,6 +193,13 @@ TEST_F(ValidateStateTest, OpenCursorsOnAllIndexes) {
// Open cursors against checkpoint'ed indexes with {background:true}.
TEST_F(ValidateStateTest, OpenCursorsOnCheckpointedIndexes) {
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
+
auto opCtx = operationContext();
createCollectionAndPopulateIt(opCtx, kNss);
@@ -214,6 +227,13 @@ TEST_F(ValidateStateTest, OpenCursorsOnCheckpointedIndexes) {
// Only open cursors against indexes that are consistent with the rest of the checkpoint'ed data.
TEST_F(ValidateStateTest, OpenCursorsOnConsistentlyCheckpointedIndexes) {
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
+
auto opCtx = operationContext();
Collection* coll = createCollectionAndPopulateIt(opCtx, kNss);
@@ -257,6 +277,13 @@ TEST_F(ValidateStateTest, OpenCursorsOnConsistentlyCheckpointedIndexes) {
// Indexes in the checkpoint that were dropped in the present should not have cursors opened against
// them.
TEST_F(ValidateStateTest, CursorsAreNotOpenedAgainstCheckpointedIndexesThatWereLaterDropped) {
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
+
auto opCtx = operationContext();
createCollectionAndPopulateIt(opCtx, kNss);
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index c1d7ad7ddba..7828e0399dd 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -1027,7 +1027,7 @@ void IndexBuildsCoordinator::onStepUp(OperationContext* opCtx) {
}
}
- if (!_signalIfCommitQuorumNotEnabled(opCtx, replState)) {
+ if (!_signalIfCommitQuorumNotEnabled(opCtx, replState, true /* onStepUp */)) {
// This reads from system.indexBuilds collection to see if commit quorum got satisfied.
_signalIfCommitQuorumIsSatisfied(opCtx, replState);
}
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index 24c80d86b4e..a475bc65504 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -607,8 +607,9 @@ protected:
* Skips the voting process and directly signal primary to commit index build if
* commit quorum is not enabled.
*/
- virtual bool _signalIfCommitQuorumNotEnabled(
- OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState) = 0;
+ virtual bool _signalIfCommitQuorumNotEnabled(OperationContext* opCtx,
+ std::shared_ptr<ReplIndexBuildState> replState,
+ bool onStepUp) = 0;
/**
* Signals the primary to commit the index build by sending "voteCommitIndexBuild" command
diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp
index c386ac34e26..f6f64573a37 100644
--- a/src/mongo/db/index_builds_coordinator_mongod.cpp
+++ b/src/mongo/db/index_builds_coordinator_mongod.cpp
@@ -393,7 +393,7 @@ void IndexBuildsCoordinatorMongod::_signalIfCommitQuorumIsSatisfied(
}
bool IndexBuildsCoordinatorMongod::_signalIfCommitQuorumNotEnabled(
- OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState) {
+ OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState, bool onStepup) {
// Locking order is important here to avoid deadlocks i.e, rstl followed by ReplIndexBuildState
// mutex.
invariant(opCtx->lockState()->isRSTLLocked());
@@ -403,7 +403,7 @@ bool IndexBuildsCoordinatorMongod::_signalIfCommitQuorumNotEnabled(
if (!enableIndexBuildCommitQuorum) {
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID);
- if (replCoord->canAcceptWritesFor(opCtx, dbAndUUID)) {
+ if (replCoord->canAcceptWritesFor(opCtx, dbAndUUID) || onStepup) {
// Node is primary here.
stdx::unique_lock<Latch> lk(replState->mutex);
_sendCommitQuorumSatisfiedSignal(lk, opCtx, replState);
diff --git a/src/mongo/db/index_builds_coordinator_mongod.h b/src/mongo/db/index_builds_coordinator_mongod.h
index 3e86e06397a..e9c2717304f 100644
--- a/src/mongo/db/index_builds_coordinator_mongod.h
+++ b/src/mongo/db/index_builds_coordinator_mongod.h
@@ -143,7 +143,8 @@ private:
bool _signalIfCommitQuorumNotEnabled(OperationContext* opCtx,
- std::shared_ptr<ReplIndexBuildState> replState) override;
+ std::shared_ptr<ReplIndexBuildState> replState,
+ bool onStepUp = false) override;
void _signalPrimaryForCommitReadiness(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState) override;
diff --git a/src/mongo/db/index_builds_coordinator_mongod_test.cpp b/src/mongo/db/index_builds_coordinator_mongod_test.cpp
index 8490b157381..cc4128756a6 100644
--- a/src/mongo/db/index_builds_coordinator_mongod_test.cpp
+++ b/src/mongo/db/index_builds_coordinator_mongod_test.cpp
@@ -82,6 +82,13 @@ void IndexBuildsCoordinatorMongodTest::setUp() {
Client::initThread(threadName.c_str());
};
_indexBuildsCoord = std::make_unique<IndexBuildsCoordinatorMongod>(options);
+
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
}
void IndexBuildsCoordinatorMongodTest::tearDown() {
diff --git a/src/mongo/db/storage/two_phase_index_build_knobs.idl b/src/mongo/db/storage/two_phase_index_build_knobs.idl
index d23c7670603..dbcdc45d1e3 100644
--- a/src/mongo/db/storage/two_phase_index_build_knobs.idl
+++ b/src/mongo/db/storage/two_phase_index_build_knobs.idl
@@ -45,4 +45,4 @@ server_parameters:
set_at: startup
cpp_vartype: bool
cpp_varname: "enableIndexBuildCommitQuorum"
- default: false
+ default: true
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp
index b9b2e0624ee..ab5076a5cfa 100644
--- a/src/mongo/dbtests/storage_timestamp_tests.cpp
+++ b/src/mongo/dbtests/storage_timestamp_tests.cpp
@@ -2122,6 +2122,13 @@ public:
class TimestampMultiIndexBuilds : public StorageTimestampTest {
public:
void run() {
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
+
auto storageEngine = _opCtx->getServiceContext()->getStorageEngine();
auto durableCatalog = storageEngine->getCatalog();
@@ -2240,6 +2247,12 @@ public:
class TimestampMultiIndexBuildsDuringRename : public StorageTimestampTest {
public:
void run() {
+ // Disable index build commit quorum as we don't have support of replication subsystem for
+ // voting.
+ ASSERT_OK(ServerParameterSet::getGlobal()
+ ->getMap()
+ .find("enableIndexBuildCommitQuorum")
+ ->second->setFromString("false"));
auto storageEngine = _opCtx->getServiceContext()->getStorageEngine();
auto durableCatalog = storageEngine->getCatalog();
diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.cpp b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
index b8a5e973946..be9c27e8a77 100644
--- a/src/mongo/embedded/index_builds_coordinator_embedded.cpp
+++ b/src/mongo/embedded/index_builds_coordinator_embedded.cpp
@@ -105,7 +105,7 @@ void IndexBuildsCoordinatorEmbedded::_signalIfCommitQuorumIsSatisfied(
}
bool IndexBuildsCoordinatorEmbedded::_signalIfCommitQuorumNotEnabled(
- OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState) {
+ OperationContext* opCtx, std::shared_ptr<ReplIndexBuildState> replState, bool onStepUp) {
MONGO_UNREACHABLE;
}
diff --git a/src/mongo/embedded/index_builds_coordinator_embedded.h b/src/mongo/embedded/index_builds_coordinator_embedded.h
index 677cc9ecf67..a83deea829d 100644
--- a/src/mongo/embedded/index_builds_coordinator_embedded.h
+++ b/src/mongo/embedded/index_builds_coordinator_embedded.h
@@ -81,7 +81,8 @@ private:
std::shared_ptr<ReplIndexBuildState> replState) override;
bool _signalIfCommitQuorumNotEnabled(OperationContext* opCtx,
- std::shared_ptr<ReplIndexBuildState> replState) override;
+ std::shared_ptr<ReplIndexBuildState> replState,
+ bool onStepUp) override;
void _signalPrimaryForCommitReadiness(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState) override;