summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2022-03-22 11:14:49 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-22 16:24:33 +0000
commit9f6d8c3847e3f837c9a71b8bc2b67c0881619aad (patch)
tree1f1cbde0ce6b48c72ad82651172bbdfed2b12ffc
parent5c32bf2de8c907b5996634dda70432be083431ff (diff)
downloadmongo-9f6d8c3847e3f837c9a71b8bc2b67c0881619aad.tar.gz
Revert "SERVER-63531 Correct error to indicate that non-voting members can be included in commitQuorum"
This reverts commit 0a38f458292dc64d5be84663bec8102d9a232f1e.
-rw-r--r--jstests/noPassthrough/commit_quorum_voting_nodes.js83
-rw-r--r--jstests/replsets/buildindexes_false_commit_quorum.js12
-rw-r--r--src/mongo/db/repl/topology_coordinator.cpp19
3 files changed, 14 insertions, 100 deletions
diff --git a/jstests/noPassthrough/commit_quorum_voting_nodes.js b/jstests/noPassthrough/commit_quorum_voting_nodes.js
deleted file mode 100644
index 87e7b1ce27a..00000000000
--- a/jstests/noPassthrough/commit_quorum_voting_nodes.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Tests that index build commitQuorum can include non-voting data-bearing nodes.
- *
- * @tags: [
- * requires_journaling,
- * requires_persistence,
- * requires_replication,
- * ]
- */
-
-(function() {
-const replSet = new ReplSetTest({
- nodes: [
- {
- rsConfig: {
- tags: {es: 'dc1'},
- }
- },
- {
- rsConfig: {
- tags: {es: 'dc2'},
- }
- },
- {
- // Analytics node with zero votes should be included in a commitQuorum.
- rsConfig: {
- priority: 0,
- votes: 0,
- tags: {es: 'analytics'},
- },
- },
- ],
-});
-
-replSet.startSet();
-replSet.initiate();
-
-const primary = replSet.getPrimary();
-const config = primary.getDB('local').system.replset.findOne();
-
-// Create a custom write concern for both nodes with the 'es' tag. We will expect this to be usable
-// as an option to commitQuorum.
-config.settings = {
- getLastErrorModes: {ESP: {"es": 3}}
-};
-config.version++;
-assert.commandWorked(primary.getDB("admin").runCommand({replSetReconfig: config}));
-
-const db = replSet.getPrimary().getDB('test');
-const coll = db['coll'];
-assert.commandWorked(coll.insert({a: 1}));
-
-// Shut the analytics node down so that it cannot contribute to the commitQuorum.
-const analyticsNodeId = 2;
-replSet.stop(analyticsNodeId, {forRestart: true});
-
-// The default commitQuorum should not include the non-voting analytics node.
-assert.commandWorked(coll.createIndex({a: 1}));
-coll.dropIndexes();
-
-// The explicit "votingMembers" should not include the non-voting analytics node.
-assert.commandWorked(coll.createIndex({a: 1}, {}, "votingMembers"));
-coll.dropIndexes();
-
-// Restart the analytics node down so that it can contribute to the commitQuorum.
-replSet.start(analyticsNodeId, {}, true /* restart */);
-
-// This should include the non-voting analytics node.
-const nNodes = replSet.nodeList().length;
-assert.commandWorked(coll.createIndex({a: 1}, {}, nNodes));
-coll.dropIndexes();
-
-// This custom tag should include the analytics node.
-assert.commandWorked(coll.createIndex({a: 1}, {}, "ESP"));
-coll.dropIndexes();
-
-// Not enough data-bearing nodes to satisfy commit quorum.
-assert.commandFailedWithCode(coll.createIndex({a: 1}, {}, nNodes + 1),
- ErrorCodes.UnsatisfiableCommitQuorum);
-coll.dropIndexes();
-
-replSet.stopSet();
-})();
diff --git a/jstests/replsets/buildindexes_false_commit_quorum.js b/jstests/replsets/buildindexes_false_commit_quorum.js
index 3811b477778..2caa757d4d3 100644
--- a/jstests/replsets/buildindexes_false_commit_quorum.js
+++ b/jstests/replsets/buildindexes_false_commit_quorum.js
@@ -21,9 +21,7 @@ const replTest = new ReplSetTest({
nodes: [
{},
{},
- {},
{rsConfig: {priority: 0, buildIndexes: false}},
- {rsConfig: {priority: 0, votes: 0, buildIndexes: false}},
]
});
replTest.startSet();
@@ -47,12 +45,12 @@ assert.commandFailedWithCode(primaryDb.runCommand({
}),
ErrorCodes.UnsatisfiableCommitQuorum);
-// With a commit quorum that includes 4 nodes, the quorum is unsatisfiable because it includes a
-// buildIndexes: false node.
+// With a commit quorum that includes all nodes, the quorum is unsatisfiable for the same reason as
+// 'votingMembers'.
assert.commandFailedWithCode(primaryDb.runCommand({
createIndexes: collName,
indexes: [{key: {y: 1}, name: 'y_1_commitQuorum_3'}],
- commitQuorum: 4,
+ commitQuorum: 3,
}),
ErrorCodes.UnsatisfiableCommitQuorum);
@@ -74,9 +72,7 @@ replTest.getSecondaries().forEach((conn) => {
});
IndexBuildTest.assertIndexes(secondaryDbs[0][collName], 2, ['_id_', indexName]);
-IndexBuildTest.assertIndexes(secondaryDbs[1][collName], 2, ['_id_', indexName]);
-IndexBuildTest.assertIndexes(secondaryDbs[2][collName], 1, ['_id_']);
-IndexBuildTest.assertIndexes(secondaryDbs[3][collName], 1, ['_id_']);
+IndexBuildTest.assertIndexes(secondaryDbs[1][collName], 1, ['_id_']);
replTest.stopSet();
}());
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp
index dcff5d75e62..f1eb6c03578 100644
--- a/src/mongo/db/repl/topology_coordinator.cpp
+++ b/src/mongo/db/repl/topology_coordinator.cpp
@@ -3648,16 +3648,16 @@ Status TopologyCoordinator::checkIfCommitQuorumCanBeSatisfied(
}
}
- bool buildIndexesFalseNodes = false;
+ bool votingBuildIndexesFalseNodes = false;
for (auto&& member : _rsConfig.members()) {
// Only count data-bearing nodes.
if (member.isArbiter()) {
continue;
}
- // Only count nodes that build indexes.
- if (!member.shouldBuildIndexes()) {
- buildIndexesFalseNodes = true;
+ // Only count voting nodes that build indexes.
+ if (member.isVoter() && !member.shouldBuildIndexes()) {
+ votingBuildIndexesFalseNodes = true;
continue;
}
@@ -3667,17 +3667,18 @@ Status TopologyCoordinator::checkIfCommitQuorumCanBeSatisfied(
}
}
- // buildIndexes:false should not be included in a commitQuorum because they never actually build
+ // Voting, buildIndexes:false nodes can be included in a commitQuorum but never actually build
// indexes and vote to commit. Provide a helpful error message to prevent users from starting
// index builds that will never commit.
- if (buildIndexesFalseNodes) {
+ if (votingBuildIndexesFalseNodes) {
return {ErrorCodes::UnsatisfiableCommitQuorum,
- str::stream() << "Commit quorum cannot depend on buildIndexes:false nodes; "
- << "use a commit quorum that excludes these nodes"};
+ str::stream()
+ << "Commit quorum cannot depend on voting buildIndexes:false nodes; "
+ << "use a commit quorum that excludes these nodes or do not give them votes"};
}
return {ErrorCodes::UnsatisfiableCommitQuorum,
- "Not enough data-bearing nodes to satisfy commit quorum"};
+ "Not enough data-bearing voting nodes to satisfy commit quorum"};
}
} // namespace repl