summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2020-04-17 14:07:07 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-22 14:52:42 +0000
commitc71316f5b57d4943aee79cb4a94734e3791f2f60 (patch)
tree5a51c023f318d3813b4b8efe4a4223cacdfa3134
parent37931b8ddf5bfbd7d2e0813df9e92002395283cf (diff)
downloadmongo-c71316f5b57d4943aee79cb4a94734e3791f2f60.tar.gz
SERVER-46823 Enable default for index commit quorum as "votingMembers".
(cherry picked from commit 7d2d87c6cc31f28f3e6fb88d7c51ef92e90aa290) SERVER-46823 Fix the jstest failure in primary_rollbacks_before_index_build_received_votes.js (cherry picked from commit f19d8ba45109afd88165e0e9af9e176f38edba14)
-rw-r--r--jstests/noPassthrough/commit_quorum.js4
-rw-r--r--jstests/replsets/noop_writes_wait_for_write_concern.js21
-rw-r--r--jstests/replsets/primary_restart_before_index_build_received_votes.js8
-rw-r--r--jstests/replsets/primary_rollbacks_before_index_build_received_votes.js12
-rw-r--r--src/mongo/db/commands/create_indexes.cpp2
5 files changed, 39 insertions, 8 deletions
diff --git a/jstests/noPassthrough/commit_quorum.js b/jstests/noPassthrough/commit_quorum.js
index b709aff33cb..269fdb4b96a 100644
--- a/jstests/noPassthrough/commit_quorum.js
+++ b/jstests/noPassthrough/commit_quorum.js
@@ -49,14 +49,14 @@ assert.commandWorked(testDB.runCommand({create: collName}));
// Use createIndex(es) to build indexes and check the commit quorum default.
let res = assert.commandWorked(testDB[collName].createIndex({x: 1}));
-assert.eq("majority", res.commitQuorum);
+assert.eq("votingMembers", res.commitQuorum);
res = assert.commandWorked(testDB[collName].createIndex({y: 1}, {}, 1));
assert.eq(1, res.commitQuorum);
// Use createIndex(es) to build indexes and check the commit quorum default.
res = assert.commandWorked(testDB[collName].createIndexes([{i: 1}]));
-assert.eq("majority", res.commitQuorum);
+assert.eq("votingMembers", res.commitQuorum);
res = assert.commandWorked(testDB[collName].createIndexes([{j: 1}], {}, 1));
assert.eq(1, res.commitQuorum);
diff --git a/jstests/replsets/noop_writes_wait_for_write_concern.js b/jstests/replsets/noop_writes_wait_for_write_concern.js
index d8c2a970a0d..b9f40f28228 100644
--- a/jstests/replsets/noop_writes_wait_for_write_concern.js
+++ b/jstests/replsets/noop_writes_wait_for_write_concern.js
@@ -8,6 +8,7 @@
(function() {
"use strict";
load('jstests/libs/write_concern_util.js');
+load('jstests/noPassthrough/libs/index_build.js');
var name = 'noop_writes_wait_for_write_concern';
var replTest = new ReplSetTest({
@@ -107,12 +108,18 @@ commands.push({
}
});
+// All voting data bearing nodes are not up for this test. So 'createIndexes' command can't succeed
+// with the default index commitQuorum value "votingMembers". So, running createIndexes cmd using
+// commit quorum "majority".
commands.push({
- req: {createIndexes: collName, indexes: [{key: {a: 1}, name: "a_1"}]},
+ req: {createIndexes: collName, indexes: [{key: {a: 1}, name: "a_1"}], commitQuorum: "majority"},
setupFunc: function() {
assert.commandWorked(coll.insert({a: 1}));
- assert.commandWorkedIgnoringWriteConcernErrors(
- db.runCommand({createIndexes: collName, indexes: [{key: {a: 1}, name: "a_1"}]}));
+ assert.commandWorkedIgnoringWriteConcernErrors(db.runCommand({
+ createIndexes: collName,
+ indexes: [{key: {a: 1}, name: "a_1"}],
+ commitQuorum: "majority"
+ }));
},
confirmFunc: function(res) {
assert.commandWorkedIgnoringWriteConcernErrors(res);
@@ -203,6 +210,14 @@ function testCommandWithWriteConcern(cmd) {
cmd.req.writeConcern = {w: 3, wtimeout: 1000};
jsTest.log("Testing " + tojson(cmd.req));
+ if (cmd.req["createIndexes"] !== undefined &&
+ !(IndexBuildTest.supportsTwoPhaseIndexBuild(primary) &&
+ IndexBuildTest.indexBuildCommitQuorumEnabled(primary))) {
+ jsTest.log(
+ "Skipping test because two phase index build and index build commit quorum are not supported.");
+ return;
+ }
+
dropTestCollection();
cmd.setupFunc();
diff --git a/jstests/replsets/primary_restart_before_index_build_received_votes.js b/jstests/replsets/primary_restart_before_index_build_received_votes.js
index 84c4914c10e..d37a7179a1e 100644
--- a/jstests/replsets/primary_restart_before_index_build_received_votes.js
+++ b/jstests/replsets/primary_restart_before_index_build_received_votes.js
@@ -22,6 +22,14 @@ const collNss = primaryColl.getFullName();
const secondary = rst.getSecondary();
const secondaryDB = secondary.getDB(dbName);
+if (!(IndexBuildTest.supportsTwoPhaseIndexBuild(primary) &&
+ IndexBuildTest.indexBuildCommitQuorumEnabled(primary))) {
+ jsTestLog(
+ 'Skipping test because two phase index build and index build commit quorum are not supported.');
+ rst.stopSet();
+ return;
+}
+
jsTestLog("Do a document write.");
assert.commandWorked(
        primaryColl.insert({_id: 0, x: 0}, {"writeConcern": {"w": "majority"}}));
diff --git a/jstests/replsets/primary_rollbacks_before_index_build_received_votes.js b/jstests/replsets/primary_rollbacks_before_index_build_received_votes.js
index 80508a1ad40..c1d17b81b40 100644
--- a/jstests/replsets/primary_rollbacks_before_index_build_received_votes.js
+++ b/jstests/replsets/primary_rollbacks_before_index_build_received_votes.js
@@ -21,6 +21,14 @@ const collNss = primaryColl.getFullName();
const secondary = rollbackTest.getSecondary();
const secondaryDB = secondary.getDB(dbName);
+if (!(IndexBuildTest.supportsTwoPhaseIndexBuild(primary) &&
+ IndexBuildTest.indexBuildCommitQuorumEnabled(primary))) {
+ jsTestLog(
+ 'Skipping test because two phase index build and index build commit quorum are not supported.');
+ rollbackTest.stop();
+ return;
+}
+
jsTestLog("Do a document write.");
assert.commandWorked(
        primaryColl.insert({_id: 0, x: 0}, {"writeConcern": {"w": "majority"}}));
@@ -48,12 +56,12 @@ jsTestLog("Resume index builds.");
IndexBuildTest.resumeIndexBuilds(secondary);
IndexBuildTest.resumeIndexBuilds(primary);
+rollbackTest.transitionToSteadyStateOperations();
+
let newPrimary = rollbackTest.getPrimary();
let newPrimaryDB = newPrimary.getDB(dbName);
IndexBuildTest.waitForIndexBuildToStop(newPrimaryDB, collName, "i_1");
-rollbackTest.transitionToSteadyStateOperations();
-
awaitBuild();
// check to see if the index was successfully created.
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index c5cb51c4924..da1dd52f056 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -303,7 +303,7 @@ boost::optional<CommitQuorumOptions> parseAndGetCommitQuorum(OperationContext* o
if (IndexBuildProtocol::kTwoPhase == protocol) {
// Setting CommitQuorum to 0 will make the index build to opt out of voting proces.
return (replCoord->isReplEnabled() && commitQuorumEnabled)
- ? CommitQuorumOptions(CommitQuorumOptions::kMajority)
+ ? CommitQuorumOptions(CommitQuorumOptions::kVotingMembers)
: CommitQuorumOptions(CommitQuorumOptions::kDisabled);
}