diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2020-03-03 01:38:37 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-03 23:55:58 +0000 |
commit | cde28e2ab957bd4a27ef240dfbfeea3cc8a70b74 (patch) | |
tree | 3d8b2f3eb8c6e3f5e0193b0138293757a8120bee /src/mongo/db | |
parent | 4258a3d30c35bbdb1506002557a7ff1e98aef490 (diff) | |
download | mongo-cde28e2ab957bd4a27ef240dfbfeea3cc8a70b74.tar.gz |
SERVER-45001 Enable commit quorum for two phase index builds by default.
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/catalog/validate_state_test.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator.h | 5 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator_mongod.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator_mongod.h | 3 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator_mongod_test.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/storage/two_phase_index_build_knobs.idl | 2 |
7 files changed, 43 insertions, 7 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 |