summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-08-24 12:25:14 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-30 14:31:38 +0000
commitcf080113fe8951ebb5a4795ad70494cbf5439493 (patch)
treefe2b0c717ad492ec844aba52ae126a51b13688b2
parent022d093fdba4f4b617c80048971ba6b3a6ad386a (diff)
downloadmongo-cf080113fe8951ebb5a4795ad70494cbf5439493.tar.gz
SERVER-50408 Change NotMaster error name to NotWritablePrimary
(cherry picked from commit 783e113bbb1bfa83630222de5b74fe95530692f0) (cherry picked from commit 91b24be9ce86be1001f3845393edcca72186ea79)
-rw-r--r--jstests/concurrency/fsm_libs/cluster.js6
-rw-r--r--jstests/core/failcommand_failpoint.js34
-rw-r--r--jstests/libs/override_methods/continuous_stepdown.js2
-rw-r--r--jstests/libs/override_methods/network_error_and_txn_override.js4
-rw-r--r--jstests/libs/override_methods/validate_collections_on_shutdown.js2
-rw-r--r--jstests/multiVersion/3_upgrade_replset.js2
-rw-r--r--jstests/multiVersion/agg_merge_upsert_supplied_cluster.js15
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/downgrade_replset.js4
-rw-r--r--jstests/multiVersion/minor_version_upgrade_replset.js4
-rw-r--r--jstests/multiVersion/upgrade_downgrade_cluster.js2
-rw-r--r--jstests/noPassthrough/auto_retry_on_network_error.js2
-rw-r--r--jstests/noPassthrough/replica_set_connection_error_codes.js10
-rw-r--r--jstests/noPassthrough/server_transaction_metrics_secondary.js6
-rw-r--r--jstests/noPassthrough/transaction_write_with_snapshot_unavailable.js4
-rw-r--r--jstests/noPassthrough/txn_override_causal_consistency.js2
-rw-r--r--jstests/replsets/catchup_takeover_two_nodes_ahead.js4
-rw-r--r--jstests/replsets/emptycapped.js2
-rw-r--r--jstests/replsets/libs/rollback_test.js2
-rw-r--r--jstests/replsets/linearizable_read_concern.js2
-rw-r--r--jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js6
-rw-r--r--jstests/replsets/retryable_commit_transaction_after_failover.js2
-rw-r--r--jstests/replsets/step_down_on_secondary.js2
-rw-r--r--jstests/replsets/stepdown.js2
-rw-r--r--jstests/replsets/stepdown_killop.js10
-rw-r--r--jstests/replsets/stepdown_long_wait_time.js9
-rw-r--r--jstests/replsets/transactions_on_secondaries_not_allowed.js14
-rw-r--r--jstests/replsets/transactions_only_allowed_on_primaries.js13
-rw-r--r--jstests/replsets/transient_txn_error_labels.js17
-rw-r--r--jstests/replsets/txn_override_unittests.js202
-rw-r--r--jstests/replsets/validate_fails_during_rollback.js3
-rw-r--r--jstests/sharding/linearizable_read_concern.js2
-rw-r--r--jstests/sharding/txn_two_phase_commit_basic.js2
-rw-r--r--src/mongo/base/error_codes.err6
-rw-r--r--src/mongo/client/dbclient_connection.cpp2
-rw-r--r--src/mongo/client/dbclient_rs.cpp2
-rw-r--r--src/mongo/client/replica_set_monitor.cpp4
-rw-r--r--src/mongo/db/catalog/capped_utils.cpp4
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp2
-rw-r--r--src/mongo/db/catalog/create_collection.cpp4
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp4
-rw-r--r--src/mongo/db/catalog/drop_database.cpp2
-rw-r--r--src/mongo/db/catalog/drop_database_test.cpp4
-rw-r--r--src/mongo/db/catalog/drop_indexes.cpp2
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp2
-rw-r--r--src/mongo/db/catalog/rename_collection_test.cpp4
-rw-r--r--src/mongo/db/cloner.cpp4
-rw-r--r--src/mongo/db/commands/collection_to_capped.cpp2
-rw-r--r--src/mongo/db/commands/create_indexes.cpp4
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp2
-rw-r--r--src/mongo/db/commands/mr.cpp2
-rw-r--r--src/mongo/db/commands/oplog_note.cpp2
-rw-r--r--src/mongo/db/commands/shutdown_d.cpp4
-rw-r--r--src/mongo/db/db.cpp2
-rw-r--r--src/mongo/db/read_concern_mongod.cpp4
-rw-r--r--src/mongo/db/repl/apply_ops.cpp2
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator.h2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp8
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp8
-rw-r--r--src/mongo/db/repl/topology_coordinator.cpp2
-rw-r--r--src/mongo/db/repl/topology_coordinator.h4
-rw-r--r--src/mongo/db/repl/topology_coordinator_v1_test.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp2
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp2
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp2
-rw-r--r--src/mongo/db/s/set_shard_version_command.cpp2
-rw-r--r--src/mongo/db/s/shard_server_catalog_cache_loader.cpp4
-rw-r--r--src/mongo/db/s/transaction_coordinator_futures_util_test.cpp6
-rw-r--r--src/mongo/db/s/transaction_coordinator_service.cpp9
-rw-r--r--src/mongo/db/s/transaction_coordinator_service.h4
-rw-r--r--src/mongo/db/s/transaction_coordinator_service_test.cpp6
-rw-r--r--src/mongo/db/service_entry_point_common.cpp15
-rw-r--r--src/mongo/db/sessions_collection_rs.cpp2
-rw-r--r--src/mongo/db/system_index.cpp2
-rw-r--r--src/mongo/db/transaction_participant.cpp8
-rw-r--r--src/mongo/db/transaction_participant.h2
-rw-r--r--src/mongo/db/transaction_participant_test.cpp20
-rw-r--r--src/mongo/db/write_concern.h2
-rw-r--r--src/mongo/rpc/op_msg_integration_test.cpp8
-rw-r--r--src/mongo/s/async_requests_sender.cpp2
-rw-r--r--src/mongo/s/catalog/dist_lock_catalog_impl.cpp2
-rw-r--r--src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp4
-rw-r--r--src/mongo/s/catalog/replset_dist_lock_manager.cpp6
-rw-r--r--src/mongo/s/catalog/replset_dist_lock_manager_test.cpp4
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client.h2
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client_impl.h2
-rw-r--r--src/mongo/s/catalog/sharding_catalog_test.cpp23
-rw-r--r--src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp20
-rw-r--r--src/mongo/s/client/shard_registry.h2
-rw-r--r--src/mongo/s/query/async_results_merger.cpp2
-rw-r--r--src/mongo/s/write_ops/batch_downconvert.cpp3
-rw-r--r--src/mongo/s/write_ops/batch_write_exec_test.cpp4
-rw-r--r--src/mongo/shell/utils.js2
-rw-r--r--src/mongo/util/assert_util_test.cpp29
95 files changed, 373 insertions, 329 deletions
diff --git a/jstests/concurrency/fsm_libs/cluster.js b/jstests/concurrency/fsm_libs/cluster.js
index 1b24c9bbdbb..cc3dc0df1c5 100644
--- a/jstests/concurrency/fsm_libs/cluster.js
+++ b/jstests/concurrency/fsm_libs/cluster.js
@@ -372,7 +372,7 @@ var Cluster = function(options) {
assert(this.isSharded(), 'cluster is not sharded');
// If we are continuously stepping down shards, the config server may have stale view of the
- // cluster, so retry on retryable errors, e.g. NotMaster.
+ // cluster, so retry on retryable errors, e.g. NotWritablePrimary.
if (this.shouldPerformContinuousStepdowns()) {
assert.soon(() => {
try {
@@ -386,7 +386,7 @@ var Cluster = function(options) {
// done.
//
// TODO SERVER-30949: Remove this try catch block once listCollections and
- // listIndexes automatically retry on NotMaster errors.
+ // listIndexes automatically retry on NotWritablePrimary errors.
if (e.code === 18630 || // listCollections failure
e.code === 18631) { // listIndexes failure
print("Caught retryable error from shardCollection, retrying: " +
@@ -497,7 +497,7 @@ var Cluster = function(options) {
// mongos is stale.
//
// TODO SERVER-30949: listCollections through mongos should automatically retry on
- // NotMaster errors. Once that is true, remove this check.
+ // NotWritablePrimary errors. Once that is true, remove this check.
if (isSteppingDownConfigServers && isMongos &&
(dbInfo.name === "admin" || dbInfo.name === "config")) {
return;
diff --git a/jstests/core/failcommand_failpoint.js b/jstests/core/failcommand_failpoint.js
index fa73c188190..c1e63af15fb 100644
--- a/jstests/core/failcommand_failpoint.js
+++ b/jstests/core/failcommand_failpoint.js
@@ -27,23 +27,23 @@ assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: "alwaysOn",
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["ping"],
threadName: threadName,
}
}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
// Configure failCommand again and verify that it still works correctly.
assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: "alwaysOn",
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["ping"],
threadName: threadName,
}
}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
assert.commandWorked(adminDB.runCommand({configureFailPoint: "failCommand", mode: "off"}));
// Test switching command sets.
@@ -51,17 +51,17 @@ assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: "alwaysOn",
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["ping"],
threadName: threadName,
}
}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: "alwaysOn",
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["isMaster"],
threadName: threadName,
}
@@ -92,12 +92,12 @@ assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: "alwaysOn",
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["ping"],
threadName: threadName,
}
}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
assert.commandWorked(adminDB.runCommand({configureFailPoint: "failCommand", mode: "off"}));
// Test that only commands specified in failCommands fail.
@@ -135,14 +135,14 @@ assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: {skip: 2},
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["ping"],
threadName: threadName,
}
}));
assert.commandWorked(testDB.runCommand({ping: 1}));
assert.commandWorked(testDB.runCommand({ping: 1}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
assert.commandWorked(adminDB.runCommand({configureFailPoint: "failCommand", mode: "off"}));
// Test times when failing with a particular error code.
@@ -150,13 +150,13 @@ assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: {times: 2},
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["ping"],
threadName: threadName,
}
}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
assert.commandWorked(testDB.runCommand({ping: 1}));
assert.commandWorked(adminDB.runCommand({configureFailPoint: "failCommand", mode: "off"}));
@@ -406,19 +406,19 @@ assert.commandWorked(adminDB.runCommand({
mode: "alwaysOn",
data: {
failCommands: ["ping"],
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
threadName: threadName,
appName: appName,
}
}));
-assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(testDB.runCommand({ping: 1}), ErrorCodes.NotWritablePrimary);
assert.commandWorked(adminDB.runCommand({
configureFailPoint: "failCommand",
mode: "alwaysOn",
data: {
failCommands: ["ping"],
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
threadName: threadName,
appName: "made up app name",
}
diff --git a/jstests/libs/override_methods/continuous_stepdown.js b/jstests/libs/override_methods/continuous_stepdown.js
index 9c7881f9d4a..894c274a26b 100644
--- a/jstests/libs/override_methods/continuous_stepdown.js
+++ b/jstests/libs/override_methods/continuous_stepdown.js
@@ -82,7 +82,7 @@ const StepdownThread = function() {
assert.commandWorkedOrFailedWithCode(
primary.adminCommand(
{replSetStepDown: options.stepdownDurationSecs, force: true}),
- [ErrorCodes.NotMaster, ErrorCodes.ConflictingOperationInProgress]);
+ [ErrorCodes.NotWritablePrimary, ErrorCodes.ConflictingOperationInProgress]);
// Wait for primary to get elected and allow the test to make some progress
// before attempting another stepdown.
diff --git a/jstests/libs/override_methods/network_error_and_txn_override.js b/jstests/libs/override_methods/network_error_and_txn_override.js
index dcc5d9207c7..4139c8aba89 100644
--- a/jstests/libs/override_methods/network_error_and_txn_override.js
+++ b/jstests/libs/override_methods/network_error_and_txn_override.js
@@ -799,8 +799,8 @@ function shouldRetryWithNetworkErrorOverride(
if (!res.ok) {
if (RetryableWritesUtil.isRetryableCode(res.code)) {
// Don't decrement retries, because the command returned before the connection was
- // closed, so a subsequent attempt will receive a network error (or NotMaster error)
- // and need to retry.
+ // closed, so a subsequent attempt will receive a network error (or NotWritablePrimary
+ // error) and need to retry.
logError("Retrying failed response with retryable code");
return kContinue;
}
diff --git a/jstests/libs/override_methods/validate_collections_on_shutdown.js b/jstests/libs/override_methods/validate_collections_on_shutdown.js
index e3d0c59b059..ddaf854567e 100644
--- a/jstests/libs/override_methods/validate_collections_on_shutdown.js
+++ b/jstests/libs/override_methods/validate_collections_on_shutdown.js
@@ -61,7 +61,7 @@ MongoRunner.validateCollectionsCallback = function(port) {
conn.adminCommand(
{replSetStepDown: kFreezeTimeSecs, force: true}),
[
- ErrorCodes.NotMaster,
+ ErrorCodes.NotWritablePrimary,
ErrorCodes.NotYetInitialized,
ErrorCodes.Unauthorized,
ErrorCodes.ConflictingOperationInProgress
diff --git a/jstests/multiVersion/3_upgrade_replset.js b/jstests/multiVersion/3_upgrade_replset.js
index ea8826c1ad7..2a4b4920d79 100644
--- a/jstests/multiVersion/3_upgrade_replset.js
+++ b/jstests/multiVersion/3_upgrade_replset.js
@@ -80,7 +80,7 @@ sleep(10 * 1000);
// Since the primary from before the upgrade took place was restarted as part of the
// upgrade/downgrade process, we explicitly reconnect to it so that sending it an update operation
-// silently fails with an unchecked NotMaster error rather than a network error.
+// silently fails with an unchecked NotPrimaryError rather than a network error.
reconnect(oldPrimary.getDB("admin"));
joinFindInsert();
diff --git a/jstests/multiVersion/agg_merge_upsert_supplied_cluster.js b/jstests/multiVersion/agg_merge_upsert_supplied_cluster.js
index a3a3f4034a1..1c7668a617c 100644
--- a/jstests/multiVersion/agg_merge_upsert_supplied_cluster.js
+++ b/jstests/multiVersion/agg_merge_upsert_supplied_cluster.js
@@ -64,17 +64,18 @@ function refreshCluster(version, components, singleShard) {
// Run the aggregation and swallow applicable exceptions for as long as we receive them, up to the
// assert.soon timeout. This is necessary because there is a period after one shard's Primary steps
// down during upgrade where a $merge on the other shard may still target the previous Primary.
-function tryWhileNotMaster(sourceColl, targetColl, pipeline, options) {
+function tryWhileNotPrimary(sourceColl, targetColl, pipeline, options) {
assert.soonNoExcept(() => {
const aggCmdParams = Object.assign({pipeline: pipeline, cursor: {}}, options);
const cmdRes = sourceColl.runCommand("aggregate", aggCmdParams);
if (cmdRes.ok) {
return true;
}
- // The only errors we are prepared to swallow are ErrorCodes.NotMaster and CursorNotFound.
- // The latter can be thrown as a consequence of a NotMaster on one shard when the $merge
- // stage is dispatched to a merging shard as part of the latter half of the pipeline.
- const errorsToSwallow = [ErrorCodes.NotMaster, ErrorCodes.CursorNotFound];
+ // The only errors we are prepared to swallow are ErrorCodes.NotWritablePrimary and
+ // CursorNotFound. The latter can be thrown as a consequence of a NotWritablePrimary on one
+ // shard when the $merge stage is dispatched to a merging shard as part of the latter half
+ // of the pipeline.
+ const errorsToSwallow = [ErrorCodes.NotWritablePrimary, ErrorCodes.CursorNotFound];
assert(errorsToSwallow.includes(cmdRes.code), () => tojson(cmdRes));
// TODO SERVER-43851: this may be susceptible to zombie writes. Ditto for all other
// occurrences of remove({}) throughout this test.
@@ -165,7 +166,7 @@ function runAllTestCases(expectedOutput) {
}
// Run the test case and confirm that the target collection matches the expected output.
- tryWhileNotMaster(testCase.sourceColl(), testCase.targetColl(), finalPipeline, aggOptions);
+ tryWhileNotPrimary(testCase.sourceColl(), testCase.targetColl(), finalPipeline, aggOptions);
assert.sameMembers(testCase.targetColl().find().toArray(), expectedOutput);
assert.commandWorked(testCase.targetColl().remove({}));
}
@@ -197,4 +198,4 @@ refreshCluster(latestVersion, {upgradeMongos: true});
runAllTestCases(expectedNewBehaviourOutput);
st.stop();
-})(); \ No newline at end of file
+})();
diff --git a/jstests/multiVersion/genericSetFCVUsage/downgrade_replset.js b/jstests/multiVersion/genericSetFCVUsage/downgrade_replset.js
index 964b0c583da..1b4cd2a6704 100644
--- a/jstests/multiVersion/genericSetFCVUsage/downgrade_replset.js
+++ b/jstests/multiVersion/genericSetFCVUsage/downgrade_replset.js
@@ -64,8 +64,8 @@ function runDowngradeTest() {
printjson(rst.status());
// Since the old primary was restarted as part of the downgrade process, we explicitly reconnect
- // to it so that sending it an update operation silently fails with an unchecked NotMaster error
- // rather than a network error.
+ // to it so that sending it an update operation silently fails with an unchecked
+ // NotWritablePrimary error rather than a network error.
reconnect(oldPrimary.getDB("admin"));
joinFindInsert();
rst.stopSet();
diff --git a/jstests/multiVersion/minor_version_upgrade_replset.js b/jstests/multiVersion/minor_version_upgrade_replset.js
index fb98e74f70e..307b8931189 100644
--- a/jstests/multiVersion/minor_version_upgrade_replset.js
+++ b/jstests/multiVersion/minor_version_upgrade_replset.js
@@ -72,8 +72,8 @@ printjson(rst.status());
sleep(10 * 1000);
// Since the old primary was restarted as part of the upgrade process, we explicitly reconnect to it
-// so that sending it an update operation silently fails with an unchecked NotMaster error rather
-// than a network error.
+// so that sending it an update operation silently fails with an unchecked NotWritablePrimary error
+// rather than a network error.
reconnect(oldPrimary.getDB("admin"));
joinFindInsert();
diff --git a/jstests/multiVersion/upgrade_downgrade_cluster.js b/jstests/multiVersion/upgrade_downgrade_cluster.js
index 7e450c87b71..1bc4af2f8d4 100644
--- a/jstests/multiVersion/upgrade_downgrade_cluster.js
+++ b/jstests/multiVersion/upgrade_downgrade_cluster.js
@@ -12,7 +12,7 @@ load('./jstests/multiVersion/libs/multi_cluster.js');
// When checking UUID consistency, the shell attempts to run a command on the node it believes is
// primary in each shard. However, this test restarts shards, and the node that is elected primary
// after the restart may be different from the original primary. Since the shell does not retry on
-// NotMaster errors, and whether or not it detects the new primary before issuing the command is
+// NotPrimaryErrors, and whether or not it detects the new primary before issuing the command is
// nondeterministic, skip the consistency check for this test.
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
diff --git a/jstests/noPassthrough/auto_retry_on_network_error.js b/jstests/noPassthrough/auto_retry_on_network_error.js
index 1c5f8465ebb..371e36fe376 100644
--- a/jstests/noPassthrough/auto_retry_on_network_error.js
+++ b/jstests/noPassthrough/auto_retry_on_network_error.js
@@ -52,7 +52,7 @@ const dbName = "test";
const collName = "auto_retry";
// The override requires the connection to be run under a session. Use the replica set URL to
-// allow automatic re-targeting of the primary on NotMaster errors.
+// allow automatic re-targeting of the primary on NotWritablePrimary errors.
const db = new Mongo(rst.getURL()).startSession({retryWrites: true}).getDatabase(dbName);
// Commands with no disconnections should work as normal.
diff --git a/jstests/noPassthrough/replica_set_connection_error_codes.js b/jstests/noPassthrough/replica_set_connection_error_codes.js
index d431415ee6d..572020e8a2d 100644
--- a/jstests/noPassthrough/replica_set_connection_error_codes.js
+++ b/jstests/noPassthrough/replica_set_connection_error_codes.js
@@ -1,6 +1,6 @@
/**
- * Tests that DBClientRS performs re-targeting when it sees an ErrorCodes.NotMaster error response
- * from a command even if "not master" doesn't appear in the message.
+ * Tests that DBClientRS performs re-targeting when it sees an ErrorCodes.NotWritablePrimary error
+ * response from a command even if "not master" doesn't appear in the message.
* @tags: [requires_replication]
*/
(function() {
@@ -59,10 +59,10 @@ rst.awaitNodesAgreeOnPrimary();
// DBClientRS will continue to send command requests to the node it believed to be primary even
// after it stepped down so long as it hasn't closed its connection.
assert.commandFailedWithCode(rsConn.getDB("test").runCommand({create: "mycoll"}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
-// However, once the server responds back with a ErrorCodes.NotMaster error, DBClientRS will
-// cause the ReplicaSetMonitor to attempt to discover the current primary.
+// However, once the server responds back with a ErrorCodes.NotWritablePrimary error, DBClientRS
+// will cause the ReplicaSetMonitor to attempt to discover the current primary.
assert.commandWorked(rsConn.getDB("test").runCommand({create: "mycoll"}));
try {
diff --git a/jstests/noPassthrough/server_transaction_metrics_secondary.js b/jstests/noPassthrough/server_transaction_metrics_secondary.js
index 9464dd77fc1..775c23b0077 100644
--- a/jstests/noPassthrough/server_transaction_metrics_secondary.js
+++ b/jstests/noPassthrough/server_transaction_metrics_secondary.js
@@ -48,7 +48,8 @@ assert.eq(0, metrics.totalCommitted);
assert.eq(0, metrics.totalStarted);
jsTestLog("Run transaction statement.");
-assert.eq(assert.throws(() => secDb[collName].findOne({_id: 0})).code, ErrorCodes.NotMaster);
+assert.eq(assert.throws(() => secDb[collName].findOne({_id: 0})).code,
+ ErrorCodes.NotWritablePrimary);
// The metrics are not affected.
metrics = assert.commandWorked(secondary.adminCommand({serverStatus: 1, repl: 0, metrics: 0}))
@@ -61,7 +62,8 @@ assert.eq(0, metrics.totalCommitted);
assert.eq(0, metrics.totalStarted);
jsTestLog("Abort the transaction.");
-assert.commandFailedWithCode(secondarySession.abortTransaction_forTesting(), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(secondarySession.abortTransaction_forTesting(),
+ ErrorCodes.NotWritablePrimary);
// The metrics are not affected.
metrics = assert.commandWorked(secondary.adminCommand({serverStatus: 1, repl: 0, metrics: 0}))
diff --git a/jstests/noPassthrough/transaction_write_with_snapshot_unavailable.js b/jstests/noPassthrough/transaction_write_with_snapshot_unavailable.js
index 65ec2a0f9a0..b1827e8f922 100644
--- a/jstests/noPassthrough/transaction_write_with_snapshot_unavailable.js
+++ b/jstests/noPassthrough/transaction_write_with_snapshot_unavailable.js
@@ -3,8 +3,8 @@
* TransientTransactionError and the error is reported at the top level, not in a writeErrors array.
*
* Other transient transaction errors are tested elsewhere: WriteConflict is tested in
- * transactions_write_conflicts.js, NotMaster is tested in transient_txn_error_labels.js, and
- * NoSuchTransaction is tested in transient_txn_error_labels_with_write_concern.js.
+ * transactions_write_conflicts.js, NotWritablePrimary is tested in transient_txn_error_labels.js,
+ * and NoSuchTransaction is tested in transient_txn_error_labels_with_write_concern.js.
*
* @tags: [uses_transactions]
*/
diff --git a/jstests/noPassthrough/txn_override_causal_consistency.js b/jstests/noPassthrough/txn_override_causal_consistency.js
index ac7c9758c96..1944d5c5dcd 100644
--- a/jstests/noPassthrough/txn_override_causal_consistency.js
+++ b/jstests/noPassthrough/txn_override_causal_consistency.js
@@ -194,7 +194,7 @@ function runTest() {
testCommit(conn, isCausal, true /*expectRetry*/);
// Network error on commit attempt.
- mockFirstCommitResponse = {ok: 0, code: ErrorCodes.NotMaster};
+ mockFirstCommitResponse = {ok: 0, code: ErrorCodes.NotWritablePrimary};
testCommit(conn, isCausal, true /*expectRetry*/);
}
}
diff --git a/jstests/replsets/catchup_takeover_two_nodes_ahead.js b/jstests/replsets/catchup_takeover_two_nodes_ahead.js
index 4cdefc8fcdc..0c55eb13423 100644
--- a/jstests/replsets/catchup_takeover_two_nodes_ahead.js
+++ b/jstests/replsets/catchup_takeover_two_nodes_ahead.js
@@ -52,9 +52,9 @@ assert.eq(ReplSetTest.State.PRIMARY,
jsTestLog('node 2 is now primary, but cannot accept writes');
// Make sure that node 2 cannot write anything. Because it is lagged and replication
-// has been stopped, it shouldn't be able to become master.
+// has been stopped, it shouldn't be able to become primary.
assert.commandFailedWithCode(nodes[2].getDB(name).bar.insert({z: 100}, writeConcern),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
// Confirm that the most up-to-date node becomes primary after the default catchup delay.
replSet.waitForState(0, ReplSetTest.State.PRIMARY, 60 * 1000);
diff --git a/jstests/replsets/emptycapped.js b/jstests/replsets/emptycapped.js
index e15322935eb..8e47dec5570 100644
--- a/jstests/replsets/emptycapped.js
+++ b/jstests/replsets/emptycapped.js
@@ -40,7 +40,7 @@ assert.eq(primaryTestDB.capped.find().itcount(),
// Truncate a capped collection on a secondary.
assert.commandFailedWithCode(secondaryTestDB.runCommand({emptycapped: 'capped'}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
// Truncate the oplog.
assert.commandFailedWithCode(primaryLocalDB.runCommand({emptycapped: "oplog.rs"}),
diff --git a/jstests/replsets/libs/rollback_test.js b/jstests/replsets/libs/rollback_test.js
index 119f044b2e7..9643dd83044 100644
--- a/jstests/replsets/libs/rollback_test.js
+++ b/jstests/replsets/libs/rollback_test.js
@@ -399,7 +399,7 @@ function RollbackTest(name = "RollbackTest", replSet) {
// the rest of the replica set, so it physically can't become the primary.
assert.soon(() => {
const res = curPrimary.adminCommand({replSetStepDown: 1, force: true});
- return (res.ok || res.code === ErrorCodes.NotMaster);
+ return (res.ok || res.code === ErrorCodes.NotWritablePrimary);
});
} catch (e) {
// Stepdown may fail if the node has already started stepping down.
diff --git a/jstests/replsets/linearizable_read_concern.js b/jstests/replsets/linearizable_read_concern.js
index 5984577a4ed..df51f7656dc 100644
--- a/jstests/replsets/linearizable_read_concern.js
+++ b/jstests/replsets/linearizable_read_concern.js
@@ -66,7 +66,7 @@ var badCmd = assert.commandFailed(secondaries[0].getDB("test").runCommand(
{"find": "foo", readConcern: {level: "linearizable"}, "maxTimeMS": 60000}));
assert.eq(badCmd.errmsg, "cannot satisfy linearizable read concern on non-primary node");
-assert.eq(badCmd.code, ErrorCodes.NotMaster);
+assert.eq(badCmd.code, ErrorCodes.NotWritablePrimary);
// This fails because you cannot specify 'afterOpTime' for linearizable read.
var opTimeCmd = assert.commandFailed(primary.getDB("test").runCommand({
diff --git a/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js b/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js
index 101c12252a0..a1e4561edd7 100644
--- a/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js
+++ b/jstests/replsets/prepared_transaction_commands_fail_on_secondaries.js
@@ -46,7 +46,7 @@ jsTestLog("Test that prepare fails on a secondary");
const txnNumber = NumberLong(priSession.getTxnNumber_forTesting());
assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand(
{prepareTransaction: 1, txnNumber: txnNumber, autocommit: false}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
const prepareTimestamp = PrepareHelpers.prepareTransaction(priSession);
rst.awaitReplication();
@@ -60,12 +60,12 @@ assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand({
txnNumber: txnNumber,
autocommit: false
}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
jsTestLog("Test that prepared abort fails on a secondary");
assert.commandFailedWithCode(secSession.getDatabase('admin').adminCommand(
{abortTransaction: 1, txnNumber: txnNumber, autocommit: false}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
jsTestLog("Test that we can still commit the transaction");
assert.commandWorked(PrepareHelpers.commitTransaction(priSession, commitTimestamp));
diff --git a/jstests/replsets/retryable_commit_transaction_after_failover.js b/jstests/replsets/retryable_commit_transaction_after_failover.js
index e9c81e6b81c..d5e9efacc60 100644
--- a/jstests/replsets/retryable_commit_transaction_after_failover.js
+++ b/jstests/replsets/retryable_commit_transaction_after_failover.js
@@ -73,7 +73,7 @@ rst.stepUp(oldSecondary);
assert.eq(oldSecondary, rst.getPrimary());
// Reconnect the connection to the new primary.
sessionDb.getMongo()._markNodeAsFailed(
- oldPrimary.host, ErrorCodes.NotMaster, "Notice that primary is not master");
+ oldPrimary.host, ErrorCodes.NotWritablePrimary, "Notice that primary is not master");
reconnect(sessionDb);
jsTest.log("commitTransaction command is retryable after failover");
diff --git a/jstests/replsets/step_down_on_secondary.js b/jstests/replsets/step_down_on_secondary.js
index 9f62465ec41..1f11e6c2747 100644
--- a/jstests/replsets/step_down_on_secondary.js
+++ b/jstests/replsets/step_down_on_secondary.js
@@ -45,7 +45,7 @@ const joinStepDownThread = startParallelShell(() => {
const freezeSecs = 24 * 60 * 60; // 24 hours
assert.commandFailedWithCode(db.adminCommand({"replSetStepDown": freezeSecs, "force": true}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
}, primary.port);
waitForCurOpByFailPointNoNS(primaryDB, "stepdownHangBeforeRSTLEnqueue");
diff --git a/jstests/replsets/stepdown.js b/jstests/replsets/stepdown.js
index 6abdd335e92..69383280576 100644
--- a/jstests/replsets/stepdown.js
+++ b/jstests/replsets/stepdown.js
@@ -174,7 +174,7 @@ try {
jsTestLog('Do stepdown of primary ' + master + ' that should not work');
assert.commandFailedWithCode(master.getDB("admin").runCommand(
{replSetStepDown: ReplSetTest.kDefaultTimeoutMS, force: true}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
// Check that the 'total' and 'failed' fields of 'replSetStepDown' and
// 'replSetStepDownWithForce' have been incremented in serverStatus.
diff --git a/jstests/replsets/stepdown_killop.js b/jstests/replsets/stepdown_killop.js
index 87d7d884a8b..d5a3cef469a 100644
--- a/jstests/replsets/stepdown_killop.js
+++ b/jstests/replsets/stepdown_killop.js
@@ -2,7 +2,8 @@
// 1. Start up a 3 node set (1 arbiter).
// 2. Stop replication on the SECONDARY using a fail point.
// 3. Do one write and then spin up a second shell which asks the PRIMARY to StepDown.
-// 4. Once StepDown has begun, attempt to do writes and confirm that they fail with NotMaster.
+// 4. Once StepDown has begun, attempt to do writes and confirm that they fail with
+// NotWritablePrimary.
// 5. Kill the stepDown operation.
// 6. Writes should become allowed again and the primary should stay primary.
@@ -59,13 +60,14 @@ assert.soon(function() {
return false;
}, "No pending stepdown command found");
-jsTestLog("Ensure that writes start failing with NotMaster errors");
+jsTestLog("Ensure that writes start failing with NotWritablePrimary errors");
assert.soonNoExcept(function() {
- assert.commandFailedWithCode(primary.getDB(name).foo.insert({x: 2}), ErrorCodes.NotMaster);
+ assert.commandFailedWithCode(primary.getDB(name).foo.insert({x: 2}),
+ ErrorCodes.NotWritablePrimary);
return true;
});
-jsTestLog("Ensure that even though writes are failing with NotMaster, we still report " +
+jsTestLog("Ensure that even though writes are failing with NotWritablePrimary, we still report " +
"ourselves as PRIMARY");
assert.eq(ReplSetTest.State.PRIMARY, primary.adminCommand('replSetGetStatus').myState);
diff --git a/jstests/replsets/stepdown_long_wait_time.js b/jstests/replsets/stepdown_long_wait_time.js
index 5958aa3a86c..890a953959d 100644
--- a/jstests/replsets/stepdown_long_wait_time.js
+++ b/jstests/replsets/stepdown_long_wait_time.js
@@ -2,7 +2,7 @@
// 1. Start up a 3 node set (1 arbiter).
// 2. Stop replication on the SECONDARY using a fail point.
// 3. Do one write and then spin up a second shell which asks the PRIMARY to StepDown.
-// 4. Once StepDown has begun, try to do a write and ensure that it fails with NotMaster
+// 4. Once StepDown has begun, try to do a write and ensure that it fails with NotWritablePrimary
// 5. Restart replication on the SECONDARY.
// 6. Wait for PRIMARY to StepDown.
@@ -52,13 +52,14 @@ assert.soon(function() {
return false;
}, "No pending stepdown command found");
-jsTestLog("Ensure that writes start failing with NotMaster errors");
+jsTestLog("Ensure that writes start failing with NotWritablePrimary errors");
assert.soonNoExcept(function() {
- assert.commandFailedWithCode(primary.getDB(name).foo.insert({x: 2}), ErrorCodes.NotMaster);
+ assert.commandFailedWithCode(primary.getDB(name).foo.insert({x: 2}),
+ ErrorCodes.NotWritablePrimary);
return true;
});
-jsTestLog("Ensure that even though writes are failing with NotMaster, we still report " +
+jsTestLog("Ensure that even though writes are failing with NotWritablePrimary, we still report " +
"ourselves as PRIMARY");
assert.eq(ReplSetTest.State.PRIMARY, primary.adminCommand('replSetGetStatus').myState);
diff --git a/jstests/replsets/transactions_on_secondaries_not_allowed.js b/jstests/replsets/transactions_on_secondaries_not_allowed.js
index 59784afe1f3..8826fff666c 100644
--- a/jstests/replsets/transactions_on_secondaries_not_allowed.js
+++ b/jstests/replsets/transactions_on_secondaries_not_allowed.js
@@ -49,11 +49,11 @@ jsTestLog("Start a read-only transaction on the secondary.");
session.startTransaction({readConcern: {level: "snapshot"}});
// Try to read a document (the first statement in the transaction) and verify that this fails.
-assert.commandFailedWithCode(sessionDb.runCommand({find: collName}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(sessionDb.runCommand({find: collName}), ErrorCodes.NotWritablePrimary);
-// The check for "NotMaster" supercedes the check for "NoSuchTransaction" in this case.
+// The check for "NotWritablePrimary" supercedes the check for "NoSuchTransaction" in this case.
jsTestLog("Make sure we are not allowed to run the commitTransaction command on the secondary.");
-assert.commandFailedWithCode(session.commitTransaction_forTesting(), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(session.commitTransaction_forTesting(), ErrorCodes.NotWritablePrimary);
/**
* Test starting a transaction and issuing an abortTransaction command.
@@ -63,18 +63,18 @@ jsTestLog("Start a different read-only transaction on the secondary.");
session.startTransaction({readConcern: {level: "snapshot"}});
// Try to read a document (the first statement in the transaction) and verify that this fails.
-assert.commandFailedWithCode(sessionDb.runCommand({find: collName}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(sessionDb.runCommand({find: collName}), ErrorCodes.NotWritablePrimary);
-// The check for "NotMaster" supercedes the check for "NoSuchTransaction" in this case.
+// The check for "NotWritablePrimary" supercedes the check for "NoSuchTransaction" in this case.
jsTestLog("Make sure we are not allowed to run the abortTransaction command on the secondary.");
-assert.commandFailedWithCode(session.abortTransaction_forTesting(), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(session.abortTransaction_forTesting(), ErrorCodes.NotWritablePrimary);
/**
* Test starting a retryable write.
*/
jsTestLog("Start a retryable write");
-assert.commandFailedWithCode(sessionDb.foo.insert({_id: 0}), ErrorCodes.NotMaster);
+assert.commandFailedWithCode(sessionDb.foo.insert({_id: 0}), ErrorCodes.NotWritablePrimary);
/**
* Test starting a read with txnNumber, but without autocommit. This fails in general because
diff --git a/jstests/replsets/transactions_only_allowed_on_primaries.js b/jstests/replsets/transactions_only_allowed_on_primaries.js
index 2ca360eca41..d95de36ea03 100644
--- a/jstests/replsets/transactions_only_allowed_on_primaries.js
+++ b/jstests/replsets/transactions_only_allowed_on_primaries.js
@@ -60,7 +60,8 @@ function testCommands(session, commands, expectedErrorCode, readPref) {
// Call abort for good measure, even though the transaction should have already been
// aborted on the server.
- assert.commandFailedWithCode(session.abortTransaction_forTesting(), ErrorCodes.NotMaster);
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NotWritablePrimary);
}
}
@@ -84,17 +85,17 @@ let readCommands = [
jsTestLog("Testing read commands.");
// Make sure read commands can not start transactions with any supported read preference.
-testCommands(secondarySession, readCommands, ErrorCodes.NotMaster, "secondary");
-testCommands(secondarySession, readCommands, ErrorCodes.NotMaster, "secondaryPreferred");
-testCommands(secondarySession, readCommands, ErrorCodes.NotMaster, "primaryPreferred");
-testCommands(secondarySession, readCommands, ErrorCodes.NotMaster, null);
+testCommands(secondarySession, readCommands, ErrorCodes.NotWritablePrimary, "secondary");
+testCommands(secondarySession, readCommands, ErrorCodes.NotWritablePrimary, "secondaryPreferred");
+testCommands(secondarySession, readCommands, ErrorCodes.NotWritablePrimary, "primaryPreferred");
+testCommands(secondarySession, readCommands, ErrorCodes.NotWritablePrimary, null);
// Test one write command. Normal write commands should already be
// disallowed on secondaries so we don't test them exhaustively here.
let writeCommands = [{insert: collName, documents: [{_id: 0}]}];
jsTestLog("Testing write commands.");
-testCommands(secondarySession, writeCommands, ErrorCodes.NotMaster, "secondary");
+testCommands(secondarySession, writeCommands, ErrorCodes.NotWritablePrimary, "secondary");
secondarySession.endSession();
diff --git a/jstests/replsets/transient_txn_error_labels.js b/jstests/replsets/transient_txn_error_labels.js
index 0a886856beb..e9bcce56d81 100644
--- a/jstests/replsets/transient_txn_error_labels.js
+++ b/jstests/replsets/transient_txn_error_labels.js
@@ -41,7 +41,7 @@ let res = secondarySessionDb.runCommand({
startTransaction: true,
autocommit: false
});
-assert.commandFailedWithCode(res, ErrorCodes.NotMaster);
+assert.commandFailedWithCode(res, ErrorCodes.NotWritablePrimary);
assert.eq(res.errorLabels, ["TransientTransactionError"]);
jsTest.log("Insert outside a transaction on secondary should fail but not return error labels");
@@ -50,7 +50,7 @@ txnNumber++;
res = secondarySessionDb.runCommand(
{insert: collName, documents: [{_id: "insert-1"}], txnNumber: NumberLong(txnNumber)});
-assert.commandFailedWithCode(res, ErrorCodes.NotMaster);
+assert.commandFailedWithCode(res, ErrorCodes.NotWritablePrimary);
assert(!res.hasOwnProperty("errorLabels"));
secondarySession.endSession();
@@ -89,22 +89,23 @@ assert.commandFailedWithCode(res, ErrorCodes.WriteConflict);
assert.eq(res.errorLabels, ["TransientTransactionError"]);
assert.commandWorked(testDB.adminCommand({configureFailPoint: "failCommand", mode: "off"}));
-jsTest.log("NotMaster returned by commitTransaction command is not TransientTransactionError");
+jsTest.log(
+ "NotWritablePrimary returned by commitTransaction command is not TransientTransactionError");
// commitTransaction will attempt to perform a noop write in response to a NoSuchTransaction
-// error and non-empty writeConcern. This will throw NotMaster.
+// error and non-empty writeConcern. This will throw NotWritablePrimary.
res = secondarySessionDb.adminCommand({
commitTransaction: 1,
txnNumber: NumberLong(secondarySession.getTxnNumber_forTesting() + 1),
autocommit: false,
writeConcern: {w: "majority"}
});
-assert.commandFailedWithCode(res, ErrorCodes.NotMaster);
+assert.commandFailedWithCode(res, ErrorCodes.NotWritablePrimary);
assert(!res.hasOwnProperty("errorLabels"));
jsTest.log(
- "NotMaster returned by coordinateCommitTransaction command is not TransientTransactionError");
+ "NotWritablePrimary returned by coordinateCommitTransaction command is not TransientTransactionError");
// coordinateCommitTransaction will attempt to perform a noop write in response to a
-// NoSuchTransaction error and non-empty writeConcern. This will throw NotMaster.
+// NoSuchTransaction error and non-empty writeConcern. This will throw NotWritablePrimary.
res = secondarySessionDb.adminCommand({
coordinateCommitTransaction: 1,
participants: [],
@@ -112,7 +113,7 @@ res = secondarySessionDb.adminCommand({
autocommit: false,
writeConcern: {w: "majority"}
});
-assert.commandFailedWithCode(res, ErrorCodes.NotMaster);
+assert.commandFailedWithCode(res, ErrorCodes.NotWritablePrimary);
assert(!res.hasOwnProperty("errorLabels"));
jsTest.log("ShutdownInProgress returned by write commands is TransientTransactionError");
diff --git a/jstests/replsets/txn_override_unittests.js b/jstests/replsets/txn_override_unittests.js
index f508afe2a99..b790af16cd1 100644
--- a/jstests/replsets/txn_override_unittests.js
+++ b/jstests/replsets/txn_override_unittests.js
@@ -339,28 +339,28 @@ const retryOnNetworkErrorTests = [
}
},
{
- name: "retry on NotMaster",
+ name: "retry on NotWritablePrimary",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
}
},
{
- name: "retry on NotMaster ordered",
+ name: "retry on NotWritablePrimary ordered",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandFailed(
testDB.runCommand({insert: collName1, documents: [{_id: 2}], ordered: true}));
}
},
{
- name: "retry on NotMaster with object change",
+ name: "retry on NotWritablePrimary with object change",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
let obj1 = {_id: 1, x: 5};
let obj2 = {_id: 2, x: 5};
assert.commandWorked(coll1.insert(obj1));
@@ -375,7 +375,7 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -386,9 +386,10 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["insert"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["insert"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -399,8 +400,11 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError and normal stepdown error",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithErrorAndWCENoRun(
- "insert", ErrorCodes.NotMaster, "NotMaster", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithErrorAndWCENoRun("insert",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -413,8 +417,8 @@ const retryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("insert",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -443,7 +447,7 @@ const retryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("insert", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun("insert", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -454,7 +458,7 @@ const retryOnNetworkErrorTests = [
name: "update with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -487,7 +491,7 @@ const retryOnNetworkErrorTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithFailPoint(["update"],
- {errorCode: ErrorCodes.NotMaster, mode: {times: 2}});
+ {errorCode: ErrorCodes.NotWritablePrimary, mode: {times: 2}});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -500,10 +504,10 @@ const retryOnNetworkErrorTests = [
name: "update with chained stepdown errors",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
// Chain multiple update errors together.
attachPostCmdFunction("update", function() {
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -533,7 +537,7 @@ const retryOnNetworkErrorTests = [
const session = testDB.getSession();
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -541,7 +545,7 @@ const retryOnNetworkErrorTests = [
session.startTransaction();
assert.commandFailedWithCode(
testDB.runCommand({update: collName1, updates: [{q: {_id: 1}, u: {$inc: {x: 1}}}]}),
- ErrorCodes.NotMaster);
+ ErrorCodes.NotWritablePrimary);
assert.commandFailedWithCode(session.abortTransaction_forTesting(),
ErrorCodes.NoSuchTransaction);
@@ -577,7 +581,8 @@ const retryOnNetworkErrorTests = [
const session = testDB.getSession();
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["commitTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["commitTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
session.startTransaction();
assert.commandWorked(coll1.insert({_id: 1}));
@@ -658,7 +663,8 @@ const retryOnNetworkErrorTests = [
const session = testDB.getSession();
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["abortTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["abortTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
session.startTransaction();
assert.commandWorked(coll1.insert({_id: 1}));
@@ -743,7 +749,7 @@ const retryOnNetworkErrorTests = [
setCommandMockResponse("createIndexes", {
ok: 0,
raw: {
- shardOne: {code: ErrorCodes.NotMaster, errmsg: "dummy"},
+ shardOne: {code: ErrorCodes.NotWritablePrimary, errmsg: "dummy"},
shardTwo: {code: ErrorCodes.InternalError, errmsg: "dummy"}
}
});
@@ -767,7 +773,7 @@ const retryOnNetworkErrorTests = [
raw: {
// Raw responses only omit a top-level code if more than one error was
// returned from a shard, so a third shard is needed.
- shardOne: {code: ErrorCodes.NotMaster, errmsg: "dummy"},
+ shardOne: {code: ErrorCodes.NotWritablePrimary, errmsg: "dummy"},
shardTwo: {ok: 1},
shardThree: {code: ErrorCodes.InternalError, errmsg: "dummy"},
}
@@ -1063,7 +1069,7 @@ const txnOverrideTests = [
name: "update with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1112,7 +1118,7 @@ const txnOverrideTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithFailPoint(["update"],
- {errorCode: ErrorCodes.NotMaster, mode: {times: 2}});
+ {errorCode: ErrorCodes.NotWritablePrimary, mode: {times: 2}});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1128,10 +1134,10 @@ const txnOverrideTests = [
name: "update with chained stepdown errors",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
// Chain multiple update errors together.
attachPostCmdFunction("update", function() {
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -1147,24 +1153,28 @@ const txnOverrideTests = [
{
name: "implicit collection creation with stepdown",
test: function() {
- failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.throws(() => coll1.insert({_id: 1}));
}
},
{
name: "implicit collection creation with WriteConcernError",
test: function() {
- failCommandWithFailPoint(
- ["create"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["create"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.throws(() => coll1.insert({_id: 1}));
}
},
{
name: "implicit collection creation with WriteConcernError and normal stepdown error",
test: function() {
- failCommandWithErrorAndWCENoRun(
- "create", ErrorCodes.NotMaster, "NotMaster", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithErrorAndWCENoRun("create",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1174,8 +1184,8 @@ const txnOverrideTests = [
failCommandWithErrorAndWCENoRun("create",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1196,7 +1206,7 @@ const txnOverrideTests = [
{
name: "implicit collection creation with WriteConcernError no success",
test: function() {
- failCommandWithWCENoRun("create", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun("create", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1224,7 +1234,8 @@ const txnOverrideTests = [
name: "commit transaction with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["commitTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["commitTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1234,9 +1245,10 @@ const txnOverrideTests = [
name: "commit transaction with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["commitTransaction"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["commitTransaction"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1247,10 +1259,10 @@ const txnOverrideTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithErrorAndWCENoRun("commitTransaction",
- ErrorCodes.NotMaster,
- "NotMaster",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1263,8 +1275,8 @@ const txnOverrideTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1288,8 +1300,8 @@ const txnOverrideTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.NoSuchTransaction,
"NoSuchTransaction",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1322,7 +1334,8 @@ const txnOverrideTests = [
name: "commit transaction with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("commitTransaction", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun(
+ "commitTransaction", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
assert.throws(() => endCurrentTransactionIfOpen());
@@ -1386,10 +1399,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("drop",
ErrorCodes.NamespaceNotFound,
"NamespaceNotFound",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
coll1.drop();
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({a: 2, b: {c: 7, d: "d is good"}}));
const cursor = coll1.find({
@@ -1421,10 +1434,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
}
},
{
- name: "retry on NotMaster",
+ name: "retry on NotWritablePrimary",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["insert"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1433,10 +1446,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
}
},
{
- name: "retry on NotMaster with object change",
+ name: "retry on NotWritablePrimary with object change",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
let obj1 = {_id: 1, x: 5};
let obj2 = {_id: 2, x: 5};
assert.commandWorked(coll1.insert(obj1));
@@ -1454,7 +1467,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["create"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1469,9 +1482,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["create"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["create"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1486,8 +1500,11 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError and normal stepdown error",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithErrorAndWCENoRun(
- "create", ErrorCodes.NotMaster, "NotMaster", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithErrorAndWCENoRun("create",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1504,8 +1521,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("create",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.throws(() => coll1.insert({_id: 1}));
}
},
@@ -1535,7 +1552,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "implicit collection creation with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("create", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun("create", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1550,7 +1567,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "update with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1603,7 +1620,7 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithFailPoint(["update"],
- {errorCode: ErrorCodes.NotMaster, mode: {times: 2}});
+ {errorCode: ErrorCodes.NotWritablePrimary, mode: {times: 2}});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 1}}));
@@ -1619,10 +1636,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "update with chained stepdown errors",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
// Chain multiple update errors together.
attachPostCmdFunction("update", function() {
- failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["update"], {errorCode: ErrorCodes.NotWritablePrimary});
});
assert.commandWorked(coll1.insert({_id: 1}));
assert.eq(coll1.find().toArray(), [{_id: 1}]);
@@ -1639,7 +1656,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commit transaction with stepdown",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(["commitTransaction"], {errorCode: ErrorCodes.NotMaster});
+ failCommandWithFailPoint(["commitTransaction"],
+ {errorCode: ErrorCodes.NotWritablePrimary});
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1654,9 +1672,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commit transaction with WriteConcernError",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["commitTransaction"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["commitTransaction"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1672,10 +1691,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
failCommandWithErrorAndWCENoRun("commitTransaction",
- ErrorCodes.NotMaster,
- "NotMaster",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary",
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1693,8 +1712,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1711,8 +1730,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.OperationFailed,
"OperationFailed",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
// After commitTransaction fails, fail it again with just the ordinary error.
attachPostCmdFunction("commitTransaction", function() {
failCommandWithFailPoint(["commitTransaction"],
@@ -1745,8 +1764,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
failCommandWithErrorAndWCENoRun("commitTransaction",
ErrorCodes.NoSuchTransaction,
"NoSuchTransaction",
- ErrorCodes.NotMaster,
- "NotMaster");
+ ErrorCodes.NotWritablePrimary,
+ "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1791,7 +1810,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commit transaction with WriteConcernError no success",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithWCENoRun("commitTransaction", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun(
+ "commitTransaction", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1}));
assert.commandWorked(coll2.insert({_id: 1}));
assert.eq(coll1.find().itcount(), 1);
@@ -1806,9 +1826,10 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
name: "commitTransaction fails with SERVER-38856",
test: function() {
assert.commandWorked(testDB.createCollection(collName1));
- failCommandWithFailPoint(
- ["create"],
- {writeConcernError: {code: ErrorCodes.NotMaster, codeName: "NotMaster"}});
+ failCommandWithFailPoint(["create"], {
+ writeConcernError:
+ {code: ErrorCodes.NotWritablePrimary, codeName: "NotWritablePrimary"}
+ });
// After commitTransaction fails, abort the transaction and drop the collection
// as if the transaction were being retried on a different node.
@@ -1817,7 +1838,8 @@ const txnOverridePlusRetryOnNetworkErrorTests = [
assert.commandWorked(mongoRunCommandOriginal.apply(testDB.getMongo(),
[dbName, {drop: collName2}, 0]));
});
- failCommandWithWCENoRun("commitTransaction", ErrorCodes.NotMaster, "NotMaster");
+ failCommandWithWCENoRun(
+ "commitTransaction", ErrorCodes.NotWritablePrimary, "NotWritablePrimary");
assert.commandWorked(coll1.insert({_id: 1, x: 2}));
assert.commandWorked(coll2.insert({_id: 2}));
assert.commandWorked(coll1.update({_id: 1}, {$inc: {x: 4}}));
diff --git a/jstests/replsets/validate_fails_during_rollback.js b/jstests/replsets/validate_fails_during_rollback.js
index 8c67d33fd1a..5d8b8aff7df 100644
--- a/jstests/replsets/validate_fails_during_rollback.js
+++ b/jstests/replsets/validate_fails_during_rollback.js
@@ -24,7 +24,8 @@ rollbackTest.transitionToSyncSourceOperationsDuringRollback();
// Wait for rollback to hang.
checkLog.contains(rollbackNode, "rollbackHangAfterTransitionToRollback fail point enabled.");
-// Try to run the validate command on the rollback node. This should fail with a NotMaster error.
+// Try to run the validate command on the rollback node. This should fail with a
+// NotMasterOrSecondary error.
assert.commandFailedWithCode(rollbackNode.getDB(dbName).runCommand({"validate": collName}),
ErrorCodes.NotMasterOrSecondary);
diff --git a/jstests/sharding/linearizable_read_concern.js b/jstests/sharding/linearizable_read_concern.js
index 9b3ac62acce..fbb5cc09255 100644
--- a/jstests/sharding/linearizable_read_concern.js
+++ b/jstests/sharding/linearizable_read_concern.js
@@ -85,7 +85,7 @@ var res = assert.commandFailed(testDB.runReadCommand({
readConcern: {level: "linearizable"},
maxTimeMS: shard0ReplTest.kDefaultTimeoutMS
}));
-assert.eq(res.code, ErrorCodes.NotMaster);
+assert.eq(res.code, ErrorCodes.NotWritablePrimary);
jsTestLog("Testing linearizable read from primaries.");
diff --git a/jstests/sharding/txn_two_phase_commit_basic.js b/jstests/sharding/txn_two_phase_commit_basic.js
index 535cbe294b7..33647b8aaf5 100644
--- a/jstests/sharding/txn_two_phase_commit_basic.js
+++ b/jstests/sharding/txn_two_phase_commit_basic.js
@@ -84,7 +84,7 @@ const startSimulatingNetworkFailures = function(connArray) {
configureFailPoint: "failCommand",
mode: {times: 10},
data: {
- errorCode: ErrorCodes.NotMaster,
+ errorCode: ErrorCodes.NotWritablePrimary,
failCommands: ["prepareTransaction", "abortTransaction", "commitTransaction"]
}
}));
diff --git a/src/mongo/base/error_codes.err b/src/mongo/base/error_codes.err
index dedeac665f8..ac4015ee47d 100644
--- a/src/mongo/base/error_codes.err
+++ b/src/mongo/base/error_codes.err
@@ -301,7 +301,7 @@ error_code("OplogQueryMinTsMissing", 326)
# Non-sequential error codes (for compatibility only)
error_code("SocketException", 9001)
error_code("OBSOLETE_RecvStaleConfig", 9996)
-error_code("NotMaster", 10107)
+error_code("NotWritablePrimary", 10107)
error_code("CannotGrowDocumentInCappedNamespace", 10003)
error_code("BSONObjectTooLarge", 10334)
error_code("DuplicateKey", 11000, extra="DuplicateKeyErrorInfo")
@@ -338,7 +338,7 @@ error_class("Interruption", ["Interrupted",
# not master at some point during command processing, regardless of whether some write may have
# happened. If you care about whether a write could have happened, check for individual codes.
error_class("NotMasterError", [
- "NotMaster",
+ "NotWritablePrimary",
"NotMasterNoSlaveOk",
"NotMasterOrSecondary",
"InterruptedDueToReplStateChange",
@@ -374,7 +374,7 @@ error_class("VoteAbortError", ["NoSuchTransaction", "ReadConcernMajorityNotEnabl
error_class("NonResumableChangeStreamError", ["ChangeStreamFatalError", "ChangeStreamHistoryLost"])
error_class("RetriableError", [
- "NotMaster",
+ "NotWritablePrimary",
"NotMasterNoSlaveOk",
"NotMasterOrSecondary",
"InterruptedDueToReplStateChange",
diff --git a/src/mongo/client/dbclient_connection.cpp b/src/mongo/client/dbclient_connection.cpp
index 400799735cb..d9db9692871 100644
--- a/src/mongo/client/dbclient_connection.cpp
+++ b/src/mongo/client/dbclient_connection.cpp
@@ -696,7 +696,7 @@ void DBClientConnection::handleNotMasterResponse(const BSONObj& replyBody,
ReplicaSetMonitorPtr monitor = ReplicaSetMonitor::get(_parentReplSetName);
if (monitor) {
monitor->failedHost(_serverAddress,
- {ErrorCodes::NotMaster,
+ {ErrorCodes::NotWritablePrimary,
str::stream() << "got not master from: " << _serverAddress
<< " of repl set: " << _parentReplSetName});
}
diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp
index e13e9c0afaf..59f7554608e 100644
--- a/src/mongo/client/dbclient_rs.cpp
+++ b/src/mongo/client/dbclient_rs.cpp
@@ -641,7 +641,7 @@ void DBClientReplicaSet::isntMaster() {
// monitor doesn't exist.
_rsm->failedHost(
_masterHost,
- {ErrorCodes::NotMaster, str::stream() << "got not master for: " << _masterHost});
+ {ErrorCodes::NotWritablePrimary, str::stream() << "got not master for: " << _masterHost});
resetMaster();
}
diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp
index 73cea67539c..60b77d7c8bc 100644
--- a/src/mongo/client/replica_set_monitor.cpp
+++ b/src/mongo/client/replica_set_monitor.cpp
@@ -769,7 +769,7 @@ Status Refresher::receivedIsMasterFromMaster(const HostAndPort& from, const IsMa
// since they don't have the same ordering with pv1 electionId.
if (reply.configVersion < _set->configVersion) {
return {
- ErrorCodes::NotMaster,
+ ErrorCodes::NotWritablePrimary,
str::stream() << "Node " << from << " believes it is primary, but its config version "
<< reply.configVersion << " is older than the most recent config version "
<< _set->configVersion};
@@ -782,7 +782,7 @@ Status Refresher::receivedIsMasterFromMaster(const HostAndPort& from, const IsMa
if (reply.configVersion == _set->configVersion && _set->maxElectionId.isSet() &&
_set->maxElectionId.compare(reply.electionId) > 0) {
return {
- ErrorCodes::NotMaster,
+ ErrorCodes::NotWritablePrimary,
str::stream() << "Node " << from << " believes it is primary, but its election id "
<< reply.electionId << " is older than the most recent election id "
<< _set->maxElectionId};
diff --git a/src/mongo/db/catalog/capped_utils.cpp b/src/mongo/db/catalog/capped_utils.cpp
index 708f93ce0db..c1d18f2e42b 100644
--- a/src/mongo/db/catalog/capped_utils.cpp
+++ b/src/mongo/db/catalog/capped_utils.cpp
@@ -63,7 +63,7 @@ Status emptyCapped(OperationContext* opCtx, const NamespaceString& collectionNam
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName);
if (userInitiatedWritesAndNotPrimary) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream()
<< "Not primary while truncating collection: " << collectionName);
}
@@ -250,7 +250,7 @@ void convertToCapped(OperationContext* opCtx,
bool userInitiatedWritesAndNotPrimary = opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName);
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while converting " << collectionName
<< " to a capped collection",
!userInitiatedWritesAndNotPrimary);
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp
index 58d90f10234..cff6c4bb97c 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -285,7 +285,7 @@ Status _collModInternal(OperationContext* opCtx,
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss);
if (userInitiatedWritesAndNotPrimary) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while setting collection options on " << nss);
}
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index b35ba5ed1b0..32df756fa25 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -75,7 +75,7 @@ Status _createView(OperationContext* opCtx,
if (opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss)) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while creating collection " << nss);
}
@@ -111,7 +111,7 @@ Status _createCollection(OperationContext* opCtx,
if (opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss)) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while creating collection " << nss);
}
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 687ffb2363b..f87fa5f1b07 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -86,7 +86,7 @@ Status _dropView(OperationContext* opCtx,
if (opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName)) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while dropping collection " << collectionName);
}
@@ -127,7 +127,7 @@ Status _dropCollection(OperationContext* opCtx,
if (opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName)) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while dropping collection " << collectionName);
}
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp
index 4c3f3675c9f..180768222e4 100644
--- a/src/mongo/db/catalog/drop_database.cpp
+++ b/src/mongo/db/catalog/drop_database.cpp
@@ -137,7 +137,7 @@ Status dropDatabase(OperationContext* opCtx, const std::string& dbName) {
opCtx->writesAreReplicated() && !replCoord->canAcceptWritesForDatabase(opCtx, dbName);
if (userInitiatedWritesAndNotPrimary) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while dropping database " << dbName);
}
diff --git a/src/mongo/db/catalog/drop_database_test.cpp b/src/mongo/db/catalog/drop_database_test.cpp
index 4cc9320cd97..7e988572ee6 100644
--- a/src/mongo/db/catalog/drop_database_test.cpp
+++ b/src/mongo/db/catalog/drop_database_test.cpp
@@ -212,12 +212,12 @@ TEST_F(DropDatabaseTest, DropDatabaseReturnsNamespaceNotFoundIfDatabaseDoesNotEx
ASSERT_EQUALS(ErrorCodes::NamespaceNotFound, dropDatabase(_opCtx.get(), _nss.db().toString()));
}
-TEST_F(DropDatabaseTest, DropDatabaseReturnsNotMasterIfNotPrimary) {
+TEST_F(DropDatabaseTest, DropDatabaseReturnsNotWritablePrimaryIfNotPrimary) {
_createCollection(_opCtx.get(), _nss);
ASSERT_OK(_replCoord->setFollowerMode(repl::MemberState::RS_SECONDARY));
ASSERT_TRUE(_opCtx->writesAreReplicated());
ASSERT_FALSE(_replCoord->canAcceptWritesForDatabase(_opCtx.get(), _nss.db()));
- ASSERT_EQUALS(ErrorCodes::NotMaster, dropDatabase(_opCtx.get(), _nss.db().toString()));
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, dropDatabase(_opCtx.get(), _nss.db().toString()));
}
/**
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp
index 2e3f2383c14..7ce11d4b467 100644
--- a/src/mongo/db/catalog/drop_indexes.cpp
+++ b/src/mongo/db/catalog/drop_indexes.cpp
@@ -199,7 +199,7 @@ Status dropIndexes(OperationContext* opCtx,
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss);
if (userInitiatedWritesAndNotPrimary) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while dropping indexes in " << nss);
}
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index 480dc086a8b..4d8f7769a7d 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -138,7 +138,7 @@ Status checkSourceAndTargetNamespaces(OperationContext* opCtx,
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
if (opCtx->writesAreReplicated() && !replCoord->canAcceptWritesFor(opCtx, source))
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while renaming collection " << source << " to "
<< target);
diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp
index c00f768759e..3d340c63807 100644
--- a/src/mongo/db/catalog/rename_collection_test.cpp
+++ b/src/mongo/db/catalog/rename_collection_test.cpp
@@ -476,12 +476,12 @@ TEST_F(RenameCollectionTest,
ASSERT_TRUE(_collectionExists(_opCtx.get(), dropPendingNss));
}
-TEST_F(RenameCollectionTest, RenameCollectionReturnsNotMasterIfNotPrimary) {
+TEST_F(RenameCollectionTest, RenameCollectionReturnsNotWritablePrimaryIfNotPrimary) {
_createCollection(_opCtx.get(), _sourceNss);
ASSERT_OK(_replCoord->setFollowerMode(repl::MemberState::RS_SECONDARY));
ASSERT_TRUE(_opCtx->writesAreReplicated());
ASSERT_FALSE(_replCoord->canAcceptWritesForDatabase(_opCtx.get(), _sourceNss.db()));
- ASSERT_EQUALS(ErrorCodes::NotMaster,
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary,
renameCollection(_opCtx.get(), _sourceNss, _targetNss, {}));
}
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 7f9d4f67b93..0d094949aa8 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -130,7 +130,7 @@ struct Cloner::Fun {
boost::optional<Lock::DBLock> dbLock;
dbLock.emplace(opCtx, _dbName, MODE_X);
uassert(
- ErrorCodes::NotMaster,
+ ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while cloning collection " << from_collection.ns()
<< " to " << to_collection.ns(),
!opCtx->writesAreReplicated() ||
@@ -773,7 +773,7 @@ Status Cloner::copyDb(OperationContext* opCtx,
}
uassert(
- ErrorCodes::NotMaster,
+ ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while cloning database " << opts.fromDB
<< " (after getting list of collections to clone)",
!opCtx->writesAreReplicated() ||
diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp
index 42b1ff38dfe..11770b05ca2 100644
--- a/src/mongo/db/commands/collection_to_capped.cpp
+++ b/src/mongo/db/commands/collection_to_capped.cpp
@@ -116,7 +116,7 @@ public:
NamespaceString nss(dbname, to);
if (!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss)) {
- uasserted(ErrorCodes::NotMaster,
+ uasserted(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while cloning collection " << from << " to "
<< to << " (as capped)");
}
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 5c9d9f7e230..7d3b619df7b 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -396,7 +396,7 @@ bool runCreateIndexes(OperationContext* opCtx,
// Do not use AutoGetOrCreateDb because we may relock the database in mode X.
Lock::DBLock dbLock(opCtx, ns.db(), MODE_IX);
if (!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, ns)) {
- uasserted(ErrorCodes::NotMaster,
+ uasserted(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while creating indexes in " << ns.ns());
}
@@ -591,7 +591,7 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
// Do not use AutoGetOrCreateDb because we may relock the database in mode X.
Lock::DBLock dbLock(opCtx, ns.db(), MODE_IX);
if (!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, ns)) {
- uasserted(ErrorCodes::NotMaster,
+ uasserted(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while creating indexes in " << ns.ns());
}
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 925299a5166..79997227131 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -170,7 +170,7 @@ void appendCommandResponse(const PlanExecutor* exec,
}
void assertCanWrite(OperationContext* opCtx, const NamespaceString& nsString) {
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while running findAndModify command on collection "
<< nsString.ns(),
repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nsString));
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 42beb6f6433..eda21279921 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -1546,7 +1546,7 @@ public:
if (state.isOnDisk()) {
// This means that it will be doing a write operation, make sure it is safe to
// do so
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
"not master",
repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(
opCtx, config.nss));
diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp
index 2899d5b602f..be10ff240a3 100644
--- a/src/mongo/db/commands/oplog_note.cpp
+++ b/src/mongo/db/commands/oplog_note.cpp
@@ -66,7 +66,7 @@ Status _performNoopWrite(OperationContext* opCtx, BSONObj msgObj, StringData not
// Its a proxy for being a primary passing "local" will cause it to return true on secondary
if (!replCoord->canAcceptWritesForDatabase(opCtx, "admin")) {
- return {ErrorCodes::NotMaster, "Not a primary"};
+ return {ErrorCodes::NotWritablePrimary, "Not a primary"};
}
writeConflictRetry(opCtx, note, NamespaceString::kRsOplogNamespace.ns(), [&opCtx, &msgObj] {
diff --git a/src/mongo/db/commands/shutdown_d.cpp b/src/mongo/db/commands/shutdown_d.cpp
index 5bf404f682e..bed8d258d0a 100644
--- a/src/mongo/db/commands/shutdown_d.cpp
+++ b/src/mongo/db/commands/shutdown_d.cpp
@@ -49,8 +49,8 @@ Status stepDownForShutdown(OperationContext* opCtx,
if (replCoord->getConfig().getNumMembers() != 1) {
try {
replCoord->stepDown(opCtx, false /* force */, waitTime, Seconds(120));
- } catch (const ExceptionFor<ErrorCodes::NotMaster>&) {
- // Ignore not master errors.
+ } catch (const ExceptionFor<ErrorCodes::NotWritablePrimary>&) {
+ // Ignore NotWritablePrimary errors.
} catch (const DBException& e) {
if (!forceShutdown) {
return e.toStatus();
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 27442f9b257..d80a165cef3 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -472,7 +472,7 @@ ExitCode _initAndListen(int listenPort) {
log() << redact(status);
if (status == ErrorCodes::AuthSchemaIncompatible) {
exitCleanly(EXIT_NEED_UPGRADE);
- } else if (status == ErrorCodes::NotMaster) {
+ } else if (status == ErrorCodes::NotWritablePrimary) {
// Try creating the indexes if we become master. If we do not become master,
// the master will create the indexes and we will replicate them.
} else {
diff --git a/src/mongo/db/read_concern_mongod.cpp b/src/mongo/db/read_concern_mongod.cpp
index b31b73b8918..510ab6288a0 100644
--- a/src/mongo/db/read_concern_mongod.cpp
+++ b/src/mongo/db/read_concern_mongod.cpp
@@ -259,7 +259,7 @@ MONGO_REGISTER_SHIM(waitForReadConcern)
}
if (!replCoord->getMemberState().primary()) {
- return {ErrorCodes::NotMaster,
+ return {ErrorCodes::NotWritablePrimary,
"cannot satisfy linearizable read concern on non-primary node"};
}
}
@@ -391,7 +391,7 @@ MONGO_REGISTER_SHIM(waitForLinearizableReadConcern)
Lock::CollectionLock lock(opCtx, NamespaceString("local.oplog.rs"), MODE_IX);
if (!replCoord->canAcceptWritesForDatabase(opCtx, "admin")) {
- return {ErrorCodes::NotMaster,
+ return {ErrorCodes::NotWritablePrimary,
"No longer primary when waiting for linearizable read concern"};
}
diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp
index 78a5dc8e5e7..c08d1ee11ef 100644
--- a/src/mongo/db/repl/apply_ops.cpp
+++ b/src/mongo/db/repl/apply_ops.cpp
@@ -395,7 +395,7 @@ Status applyOps(OperationContext* opCtx,
opCtx->writesAreReplicated() && !replCoord->canAcceptWritesForDatabase(opCtx, dbName);
if (userInitiatedWritesAndNotPrimary)
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream() << "Not primary while applying ops to database " << dbName);
if (auto preCondition = info.getPreCondition()) {
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index 1733f031577..274baef232a 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -469,10 +469,10 @@ TEST_F(CollectionClonerTest, CollectionClonerReturnsLastRetriableErrorOnExceedin
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(ErrorCodes::HostNotFound, "");
processNetworkResponse(ErrorCodes::NetworkTimeout, "");
- processNetworkResponse(ErrorCodes::NotMaster, "");
+ processNetworkResponse(ErrorCodes::NotWritablePrimary, "");
}
collectionCloner->join();
- ASSERT_EQUALS(ErrorCodes::NotMaster, getStatus());
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, getStatus());
}
TEST_F(CollectionClonerTest, CollectionClonerReturnsNoSuchKeyOnMissingDocumentCountFieldName) {
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index 1cdbba25b7a..f32a88536e1 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -199,7 +199,7 @@ public:
* the data has been sufficiently replicated
* ErrorCodes::ExceededTimeLimit if the opCtx->getMaxTimeMicrosRemaining is reached before
* the data has been sufficiently replicated
- * ErrorCodes::NotMaster if the node is not Primary/Master
+ * ErrorCodes::NotWritablePrimary if the node is not a writable primary
* ErrorCodes::UnknownReplWriteConcern if the writeConcern.wMode contains a write concern
* mode that is not known
* ErrorCodes::ShutdownInProgress if we are mid-shutdown
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 4f706aa7dc1..583aa452901 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2030,7 +2030,9 @@ void ReplicationCoordinatorImpl::stepDown(OperationContext* opCtx,
// Note this check is inherently racy - it's always possible for the node to stepdown from some
// other path before we acquire the global exclusive lock. This check is just to try to save us
// from acquiring the global X lock unnecessarily.
- uassert(ErrorCodes::NotMaster, "not primary so can't step down", getMemberState().primary());
+ uassert(ErrorCodes::NotWritablePrimary,
+ "not primary so can't step down",
+ getMemberState().primary());
CurOpFailpointHelpers::waitWhileFailPointEnabled(
&stepdownHangBeforeRSTLEnqueue, opCtx, "stepdownHangBeforeRSTLEnqueue");
@@ -2335,7 +2337,7 @@ Status ReplicationCoordinatorImpl::checkCanServeReadsFor_UNSAFE(OperationContext
if (opCtx->inMultiDocumentTransaction()) {
if (!_readWriteAbility->canAcceptNonLocalWrites_UNSAFE()) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
"Multi-document transactions are only allowed on replica set primaries.");
}
}
@@ -2636,7 +2638,7 @@ Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* opCt
invariant(_rsConfig.isInitialized());
if (!args.force && !_getMemberState_inlock().primary()) {
- return Status(ErrorCodes::NotMaster,
+ return Status(ErrorCodes::NotWritablePrimary,
str::stream()
<< "replSetReconfig should only be run on PRIMARY, but my state is "
<< _getMemberState_inlock().toString()
diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
index 738ff86ef87..bfbaf1ae31d 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -68,7 +68,7 @@ TEST_F(ReplCoordTest, NodeReturnsNotYetInitializedWhenReconfigReceivedPriorToIni
ASSERT_TRUE(result.obj().isEmpty());
}
-TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenReconfigReceivedWhileSecondary) {
+TEST_F(ReplCoordTest, NodeReturnsNotWritablePrimaryWhenReconfigReceivedWhileSecondary) {
// start up, become secondary, receive reconfig
init();
assertStartSuccess(BSON("_id"
@@ -88,7 +88,7 @@ TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenReconfigReceivedWhileSecondary) {
ReplSetReconfigArgs args;
args.force = false;
const auto opCtx = makeOperationContext();
- ASSERT_EQUALS(ErrorCodes::NotMaster,
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary,
getReplCoord()->processReplSetReconfig(opCtx.get(), args, &result));
ASSERT_TRUE(result.obj().isEmpty());
}
@@ -609,7 +609,7 @@ TEST_F(ReplCoordTest, NodeAcceptsConfigFromAReconfigWithForceTrueWhileNotPrimary
<< BSON("_id" << 2 << "host"
<< "node2:12345")));
const auto opCtx = makeOperationContext();
- ASSERT_EQUALS(ErrorCodes::NotMaster,
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary,
getReplCoord()->processReplSetReconfig(opCtx.get(), args, &result));
// forced should succeed
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index 34038462e90..a1d1d31ed87 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -1189,8 +1189,8 @@ TEST_F(ReplCoordTest,
}
TEST_F(ReplCoordTest, NodeReturnsNotMasterWhenSteppingDownBeforeSatisfyingAWriteConcern) {
- // Test that a thread blocked in awaitReplication will be woken up and return NotMaster
- // if the node steps down while it is waiting.
+ // Test that a thread blocked in awaitReplication will be woken up and return PrimarySteppedDown
+ // (a NotMasterError) if the node steps down while it is waiting.
assertStartSuccess(BSON("_id"
<< "mySet"
<< "version" << 2 << "members"
@@ -1909,7 +1909,7 @@ TEST_F(StepDownTestWithUnelectableNode,
ASSERT_TRUE(repl->getMemberState().secondary());
}
-TEST_F(StepDownTest, NodeReturnsNotMasterWhenAskedToStepDownAsANonPrimaryNode) {
+TEST_F(StepDownTest, NodeReturnsNotWritablePrimaryWhenAskedToStepDownAsANonPrimaryNode) {
const auto opCtx = makeOperationContext();
OpTimeWithTermOne optime1(100, 1);
@@ -1922,7 +1922,7 @@ TEST_F(StepDownTest, NodeReturnsNotMasterWhenAskedToStepDownAsANonPrimaryNode) {
ASSERT_THROWS_CODE(
getReplCoord()->stepDown(opCtx.get(), false, Milliseconds(0), Milliseconds(0)),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
ASSERT_TRUE(getReplCoord()->getMemberState().secondary());
}
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp
index 3a563899472..2caaddd5c33 100644
--- a/src/mongo/db/repl/topology_coordinator.cpp
+++ b/src/mongo/db/repl/topology_coordinator.cpp
@@ -1360,7 +1360,7 @@ TopologyCoordinator::prepareForStepDownAttempt() {
}
if (_leaderMode == LeaderMode::kNotLeader) {
- return Status{ErrorCodes::NotMaster, "This node is not a primary."};
+ return Status{ErrorCodes::NotWritablePrimary, "This node is not a primary."};
}
invariant(_leaderMode == LeaderMode::kMaster || _leaderMode == LeaderMode::kLeaderElect);
diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h
index 773442cc684..3bce7611c92 100644
--- a/src/mongo/db/repl/topology_coordinator.h
+++ b/src/mongo/db/repl/topology_coordinator.h
@@ -548,11 +548,11 @@ public:
* when we receive a stepdown command (which can fail if not enough secondaries are caught up)
* to ensure that we never process more than one stepdown request at a time.
* Returns OK if it is safe to continue with the stepdown attempt, or returns:
- * - NotMaster if this node is not a leader.
+ * - NotWritablePrimary if this node is not a leader.
* - ConflictingOperationInProgess if this node is already processing a stepdown request of any
* kind.
* On an OK return status also returns a function object that can be called to abort the
- * pending stepdown attempt and return this node to normal primary/master state.
+ * pending stepdown attempt and return this node to normal (writable) primary state.
*/
StatusWith<StepDownAttemptAbortFn> prepareForStepDownAttempt();
diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
index df13a508780..db2a4fbc433 100644
--- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
@@ -2424,7 +2424,7 @@ TEST_F(TopoCoordTest, PrepareStepDownAttemptFailsIfNotLeader) {
<< "protocolVersion" << 1),
0);
getTopoCoord().changeMemberState_forTest(MemberState::RS_SECONDARY);
- Status expectedStatus(ErrorCodes::NotMaster, "This node is not a primary. ");
+ Status expectedStatus(ErrorCodes::NotWritablePrimary, "This node is not a primary. ");
ASSERT_EQUALS(expectedStatus, getTopoCoord().prepareForStepDownAttempt().getStatus());
}
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
index 4d81a3f424b..b00cbfc5674 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp
@@ -359,7 +359,7 @@ StatusWith<ShardType> ShardingCatalogManager::_validateHostAsShard(
<< connectionString.toString() << " as a shard");
}
if (!isMaster) {
- return {ErrorCodes::NotMaster,
+ return {ErrorCodes::NotWritablePrimary,
str::stream()
<< connectionString.toString()
<< " does not have a master. If this is a replica set, ensure that it has a"
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
index 1d9eca8dbb4..b17f14298d7 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
@@ -713,7 +713,7 @@ StatusWith<BSONObj> MigrationChunkClonerSourceLegacy::_callRecipient(const BSONO
responseStatus = args.response;
});
- // TODO: Update RemoteCommandTargeter on NotMaster errors.
+ // TODO: Update RemoteCommandTargeter on NotWritablePrimary errors.
if (!scheduleStatus.isOK()) {
return scheduleStatus.getStatus();
}
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index 66d95751f78..bff99cf7029 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -597,7 +597,7 @@ void MigrationDestinationManager::cloneCollectionIndexesAndOptions(OperationCont
// Checks that the collection's UUID matches the donor's.
auto checkUUIDsMatch = [&](const Collection* collection) {
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
str::stream() << "Unable to create collection " << nss.ns()
<< " because the node is not primary",
repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, nss));
diff --git a/src/mongo/db/s/set_shard_version_command.cpp b/src/mongo/db/s/set_shard_version_command.cpp
index 10564146ca4..6fd9245607f 100644
--- a/src/mongo/db/s/set_shard_version_command.cpp
+++ b/src/mongo/db/s/set_shard_version_command.cpp
@@ -213,7 +213,7 @@ public:
autoDb.emplace(opCtx, nss.db(), MODE_IS);
// Slave nodes cannot support set shard version
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
str::stream() << "setShardVersion with collection version is only supported "
"against primary nodes, but it was received for namespace "
<< nss.ns(),
diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp
index 19181c78741..18a3edd0750 100644
--- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp
+++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp
@@ -487,7 +487,7 @@ void ShardServerCatalogCacheLoader::waitForCollectionFlush(OperationContext* opC
boost::optional<uint64_t> taskNumToWait;
while (true) {
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
str::stream() << "Unable to wait for collection metadata flush for " << nss.ns()
<< " because the node's replication role changed.",
_role == ReplicaSetRole::Primary && _term == initialTerm);
@@ -538,7 +538,7 @@ void ShardServerCatalogCacheLoader::waitForDatabaseFlush(OperationContext* opCtx
boost::optional<uint64_t> taskNumToWait;
while (true) {
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
str::stream() << "Unable to wait for database metadata flush for "
<< dbName.toString()
<< " because the node's replication role changed.",
diff --git a/src/mongo/db/s/transaction_coordinator_futures_util_test.cpp b/src/mongo/db/s/transaction_coordinator_futures_util_test.cpp
index e3df22d9b7c..710b6c241af 100644
--- a/src/mongo/db/s/transaction_coordinator_futures_util_test.cpp
+++ b/src/mongo/db/s/transaction_coordinator_futures_util_test.cpp
@@ -251,7 +251,7 @@ TEST(TransactionCoordinatorFuturesUtilTest,
promises[0].setError(errorStatus1);
ASSERT(!resultFuture.isReady());
- Status errorStatus2{ErrorCodes::NotMaster, "dummy error"};
+ Status errorStatus2{ErrorCodes::NotWritablePrimary, "dummy error"};
promises[1].setError(errorStatus2);
ASSERT(!resultFuture.isReady());
@@ -643,11 +643,11 @@ TEST_F(AsyncWorkSchedulerTest, DestroyingSchedulerCapturedInFutureCallback) {
future.get();
}
-TEST_F(AsyncWorkSchedulerTest, NotifiesRemoteCommandTargeter_CmdResponseNotMasterError) {
+TEST_F(AsyncWorkSchedulerTest, NotifiesRemoteCommandTargeter_CmdResponseNotWritablePrimaryError) {
ASSERT_EQ(0UL, getShardTargeterMock(kShardIds[1])->getAndClearMarkedDownHosts().size());
scheduleAWSRemoteCommandWithResponse(kShardIds[1],
- BSON("ok" << 0 << "code" << ErrorCodes::NotMaster
+ BSON("ok" << 0 << "code" << ErrorCodes::NotWritablePrimary
<< "errmsg"
<< "dummy"));
diff --git a/src/mongo/db/s/transaction_coordinator_service.cpp b/src/mongo/db/s/transaction_coordinator_service.cpp
index ffdc5fd8c26..177749769f4 100644
--- a/src/mongo/db/s/transaction_coordinator_service.cpp
+++ b/src/mongo/db/s/transaction_coordinator_service.cpp
@@ -92,8 +92,8 @@ void TransactionCoordinatorService::reportCoordinators(OperationContext* opCtx,
std::shared_ptr<CatalogAndScheduler> cas;
try {
cas = _getCatalogAndScheduler(opCtx);
- } catch (ExceptionFor<ErrorCodes::NotMaster>&) {
- // If we are not master, don't include any output for transaction coordinators in
+ } catch (ExceptionFor<ErrorCodes::NotWritablePrimary>&) {
+ // If we are not primary, don't include any output for transaction coordinators in
// the curOp command.
return;
}
@@ -263,8 +263,9 @@ void TransactionCoordinatorService::onShardingInitialization(OperationContext* o
std::shared_ptr<TransactionCoordinatorService::CatalogAndScheduler>
TransactionCoordinatorService::_getCatalogAndScheduler(OperationContext* opCtx) {
stdx::unique_lock<Latch> ul(_mutex);
- uassert(
- ErrorCodes::NotMaster, "Transaction coordinator is not a primary", _catalogAndScheduler);
+ uassert(ErrorCodes::NotWritablePrimary,
+ "Transaction coordinator is not a primary",
+ _catalogAndScheduler);
return _catalogAndScheduler;
}
diff --git a/src/mongo/db/s/transaction_coordinator_service.h b/src/mongo/db/s/transaction_coordinator_service.h
index a4fe1ce16f9..f50a511a8a3 100644
--- a/src/mongo/db/s/transaction_coordinator_service.h
+++ b/src/mongo/db/s/transaction_coordinator_service.h
@@ -135,8 +135,8 @@ private:
};
/**
- * Returns the current catalog + scheduler if stepUp has started, otherwise throws a NotMaster
- * exception.
+ * Returns the current catalog + scheduler if stepUp has started, otherwise throws a
+ * NotWritablePrimary exception.
*/
std::shared_ptr<CatalogAndScheduler> _getCatalogAndScheduler(OperationContext* opCtx);
diff --git a/src/mongo/db/s/transaction_coordinator_service_test.cpp b/src/mongo/db/s/transaction_coordinator_service_test.cpp
index 73a7370ac2e..d49299c8bd8 100644
--- a/src/mongo/db/s/transaction_coordinator_service_test.cpp
+++ b/src/mongo/db/s/transaction_coordinator_service_test.cpp
@@ -198,17 +198,17 @@ TEST_F(TransactionCoordinatorServiceStepUpStepDownTest, OperationsFailBeforeStep
ASSERT_THROWS_CODE(service()->createCoordinator(
operationContext(), makeLogicalSessionIdForTest(), 0, kCommitDeadline),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
ASSERT_THROWS_CODE(service()->coordinateCommit(
operationContext(), makeLogicalSessionIdForTest(), 0, kTwoShardIdSet),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
ASSERT_THROWS_CODE(
service()->recoverCommit(operationContext(), makeLogicalSessionIdForTest(), 0),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
}
TEST_F(TransactionCoordinatorServiceStepUpStepDownTest, OperationsBlockBeforeStepUpCompletes) {
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 799cbcabf5b..6dfc0a5a4c3 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -782,9 +782,9 @@ void execCommandDatabase(OperationContext* opCtx,
}
if (MONGO_FAIL_POINT(respondWithNotPrimaryInCommandDispatch)) {
- uassert(ErrorCodes::NotMaster, "not primary", canRunHere);
+ uassert(ErrorCodes::NotWritablePrimary, "not primary", canRunHere);
} else {
- uassert(ErrorCodes::NotMaster, "not master", canRunHere);
+ uassert(ErrorCodes::NotWritablePrimary, "not master", canRunHere);
}
if (!command->maintenanceOk() &&
@@ -1075,7 +1075,7 @@ DbResponse receivedCommands(OperationContext* opCtx,
// Close the connection to get client to go through server selection again.
if (LastError::get(opCtx->getClient()).hadNotMasterError()) {
notMasterUnackWrites.increment();
- uasserted(ErrorCodes::NotMaster,
+ uasserted(ErrorCodes::NotWritablePrimary,
str::stream()
<< "Not-master error while processing '" << request.getCommandName()
<< "' operation on '" << request.getDatabase() << "' database via "
@@ -1400,12 +1400,13 @@ DbResponse ServiceEntryPointCommon::handleRequest(OperationContext* opCtx,
<< redact(ue);
debug.errInfo = ue.toStatus();
}
- // A NotMaster error can be set either within receivedInsert/receivedUpdate/receivedDelete
- // or within the AssertionException handler above. Either way, we want to throw an
- // exception here, which will cause the client to be disconnected.
+ // A NotWritablePrimary error can be set either within
+ // receivedInsert/receivedUpdate/receivedDelete or within the AssertionException handler
+ // above. Either way, we want to throw an exception here, which will cause the client to be
+ // disconnected.
if (LastError::get(opCtx->getClient()).hadNotMasterError()) {
notMasterLegacyUnackWrites.increment();
- uasserted(ErrorCodes::NotMaster,
+ uasserted(ErrorCodes::NotWritablePrimary,
str::stream()
<< "Not-master error while processing '" << networkOpToString(op)
<< "' operation on '" << nsString << "' namespace via legacy "
diff --git a/src/mongo/db/sessions_collection_rs.cpp b/src/mongo/db/sessions_collection_rs.cpp
index 0069d3372f3..a7f60a18b5f 100644
--- a/src/mongo/db/sessions_collection_rs.cpp
+++ b/src/mongo/db/sessions_collection_rs.cpp
@@ -95,7 +95,7 @@ auto runIfStandaloneOrPrimary(const NamespaceString& ns, OperationContext* opCtx
// There is a window here where we may transition from Primary to
// Secondary after we release the locks we take above. In this case,
- // the callback we run below may return a NotMaster error, or a stale
+ // the callback we run below may return a NotWritablePrimary error, or a stale
// read. However, this is preferable to running the callback while
// we hold locks, since that can lead to a deadlock.
isStandaloneOrPrimary = coord->canAcceptWritesForDatabase(opCtx, ns.db());
diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp
index 28c27b67460..664061af0d9 100644
--- a/src/mongo/db/system_index.cpp
+++ b/src/mongo/db/system_index.cpp
@@ -102,7 +102,7 @@ SharedSemiFuture<ReplIndexBuildState::IndexCatalogStats> generateSystemIndexForE
const IndexSpec& spec) {
// Do not try to generate any system indexes on a secondary.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
"Not primary while creating authorization index",
replCoord->getReplicationMode() != repl::ReplicationCoordinator::modeReplSet ||
replCoord->canAcceptWritesForDatabase(opCtx, ns.db()));
diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp
index 7a103bbb632..73a1b67ed8e 100644
--- a/src/mongo/db/transaction_participant.cpp
+++ b/src/mongo/db/transaction_participant.cpp
@@ -324,7 +324,7 @@ void TransactionParticipant::performNoopWrite(OperationContext* opCtx, StringDat
Lock::DBLock dbLock(opCtx, "local", MODE_IX);
Lock::CollectionLock collectionLock(opCtx, NamespaceString::kRsOplogNamespace, MODE_IX);
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
"Not primary when performing noop write for {}"_format(msg),
replCoord->canAcceptWritesForDatabase(opCtx, "admin"));
@@ -490,7 +490,7 @@ void TransactionParticipant::Participant::beginOrContinue(OperationContext* opCt
repl::ReplicationStateTransitionLockGuard rstl(opCtx, MODE_IX);
if (opCtx->writesAreReplicated()) {
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
"Not primary so we cannot begin or continue a transaction",
replCoord->canAcceptWritesForDatabase(opCtx, "admin"));
// Disallow multi-statement transactions on shard servers that have
@@ -1369,7 +1369,7 @@ void TransactionParticipant::Participant::commitPreparedTransaction(
const auto replCoord = repl::ReplicationCoordinator::get(opCtx);
if (opCtx->writesAreReplicated()) {
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
"Not primary so we cannot commit a prepared transaction",
replCoord->canAcceptWritesForDatabase(opCtx, "admin"));
}
@@ -1545,7 +1545,7 @@ void TransactionParticipant::Participant::_abortActivePreparedTransaction(Operat
if (opCtx->writesAreReplicated()) {
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- uassert(ErrorCodes::NotMaster,
+ uassert(ErrorCodes::NotWritablePrimary,
"Not primary so we cannot abort a prepared transaction",
replCoord->canAcceptWritesForDatabase(opCtx, "admin"));
}
diff --git a/src/mongo/db/transaction_participant.h b/src/mongo/db/transaction_participant.h
index 1fde3ab0404..61b54df1fee 100644
--- a/src/mongo/db/transaction_participant.h
+++ b/src/mongo/db/transaction_participant.h
@@ -391,7 +391,7 @@ public:
* currently active one or the last one which committed
* - PreparedTransactionInProgress - if the transaction is in the prepared state and a new
* transaction or retryable write is attempted
- * - NotMaster - if the node is not a primary when this method is called.
+ * - NotWritablePrimary - if the node is not a primary when this method is called.
* - IncompleteTransactionHistory - if an attempt is made to begin a retryable write for a
* TransactionParticipant that is not in retryable write mode. This is expected behavior if
* a retryable write has been upgraded to a transaction by the server, which can happen e.g.
diff --git a/src/mongo/db/transaction_participant_test.cpp b/src/mongo/db/transaction_participant_test.cpp
index 507ecc17c34..631b6bdff14 100644
--- a/src/mongo/db/transaction_participant_test.cpp
+++ b/src/mongo/db/transaction_participant_test.cpp
@@ -936,8 +936,9 @@ TEST_F(TxnParticipantTest, StepDownDuringPreparedAbortFails) {
ASSERT_OK(repl::ReplicationCoordinator::get(opCtx())->setFollowerMode(
repl::MemberState::RS_SECONDARY));
- ASSERT_THROWS_CODE(
- txnParticipant.abortTransaction(opCtx()), AssertionException, ErrorCodes::NotMaster);
+ ASSERT_THROWS_CODE(txnParticipant.abortTransaction(opCtx()),
+ AssertionException,
+ ErrorCodes::NotWritablePrimary);
}
TEST_F(TxnParticipantTest, StepDownDuringPreparedCommitFails) {
@@ -952,7 +953,7 @@ TEST_F(TxnParticipantTest, StepDownDuringPreparedCommitFails) {
repl::MemberState::RS_SECONDARY));
ASSERT_THROWS_CODE(txnParticipant.commitPreparedTransaction(opCtx(), commitTS, {}),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
}
TEST_F(TxnParticipantTest, StepDownDuringPreparedAbortReleasesRSTL) {
@@ -992,8 +993,9 @@ TEST_F(TxnParticipantTest, StepDownDuringPreparedAbortReleasesRSTL) {
MODE_NONE);
ASSERT_OK(repl::ReplicationCoordinator::get(opCtx())->setFollowerMode(
repl::MemberState::RS_SECONDARY));
- ASSERT_THROWS_CODE(
- txnParticipant.abortTransaction(opCtx()), AssertionException, ErrorCodes::NotMaster);
+ ASSERT_THROWS_CODE(txnParticipant.abortTransaction(opCtx()),
+ AssertionException,
+ ErrorCodes::NotWritablePrimary);
ASSERT_EQ(opCtx()->lockState()->getLockMode(resourceIdReplicationStateTransitionLock),
MODE_NONE);
@@ -1047,7 +1049,7 @@ TEST_F(TxnParticipantTest, StepDownDuringPreparedCommitReleasesRSTL) {
ASSERT_THROWS_CODE(
txnParticipant.commitPreparedTransaction(opCtx(), prepareTimestamp, boost::none),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
ASSERT_EQ(opCtx()->lockState()->getLockMode(resourceIdReplicationStateTransitionLock),
MODE_NONE);
@@ -1105,7 +1107,7 @@ TEST_F(TxnParticipantTest, CannotStartNewTransactionIfNotPrimary) {
ASSERT_THROWS_CODE(
txnParticipant.beginOrContinue(opCtx(), *opCtx()->getTxnNumber(), false, true),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
}
TEST_F(TxnParticipantTest, CannotStartRetryableWriteIfNotPrimary) {
@@ -1119,7 +1121,7 @@ TEST_F(TxnParticipantTest, CannotStartRetryableWriteIfNotPrimary) {
ASSERT_THROWS_CODE(
txnParticipant.beginOrContinue(opCtx(), *opCtx()->getTxnNumber(), boost::none, true),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
}
TEST_F(TxnParticipantTest, CannotContinueTransactionIfNotPrimary) {
@@ -1136,7 +1138,7 @@ TEST_F(TxnParticipantTest, CannotContinueTransactionIfNotPrimary) {
ASSERT_THROWS_CODE(
txnParticipant.beginOrContinue(opCtx(), *opCtx()->getTxnNumber(), false, false),
AssertionException,
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
}
TEST_F(TxnParticipantTest, OlderTransactionFailsOnSessionWithNewerTransaction) {
diff --git a/src/mongo/db/write_concern.h b/src/mongo/db/write_concern.h
index 1c9516a7c6d..c8c52bbf348 100644
--- a/src/mongo/db/write_concern.h
+++ b/src/mongo/db/write_concern.h
@@ -94,7 +94,7 @@ struct WriteConcernResult {
* if this opTime.isNull() no replication-related write concern options will be enforced.
*
* Returns result of the write concern if successful.
- * Returns NotMaster if the host steps down while waiting for replication
+ * Returns NotWritablePrimary if the host steps down while waiting for replication
* Returns UnknownReplWriteConcern if the wMode specified was not enforceable
*/
Status waitForWriteConcern(OperationContext* opCtx,
diff --git a/src/mongo/rpc/op_msg_integration_test.cpp b/src/mongo/rpc/op_msg_integration_test.cpp
index 8ee613a3616..30138f70cf6 100644
--- a/src/mongo/rpc/op_msg_integration_test.cpp
+++ b/src/mongo/rpc/op_msg_integration_test.cpp
@@ -157,7 +157,7 @@ TEST(OpMsg, DocumentSequenceMaxWriteBatchWorks) {
conn->dropCollection("test.collection");
}
-TEST(OpMsg, CloseConnectionOnFireAndForgetNotMasterError) {
+TEST(OpMsg, CloseConnectionOnFireAndForgetNotWritablePrimaryError) {
const auto connStr = unittest::getFixtureConnectionString();
// This test only works against a replica set.
@@ -184,14 +184,14 @@ TEST(OpMsg, CloseConnectionOnFireAndForgetNotMasterError) {
})"))
.serialize();
- // Round-trip command fails with NotMaster error. Note that this failure is in command
- // dispatch which ignores w:0.
+ // Round-trip command fails with NotWritablePrimary error. Note that this failure is in
+ // command dispatch which ignores w:0.
Message reply;
ASSERT(conn.call(request, reply, /*assertOK*/ true, nullptr));
ASSERT_EQ(
getStatusFromCommandResult(
conn.parseCommandReplyMessage(conn.getServerAddress(), reply)->getCommandReply()),
- ErrorCodes::NotMaster);
+ ErrorCodes::NotWritablePrimary);
// Fire-and-forget closes connection when it sees that error. Note that this is using call()
// rather than say() so that we get an error back when the connection is closed. Normally
diff --git a/src/mongo/s/async_requests_sender.cpp b/src/mongo/s/async_requests_sender.cpp
index 7ecfe36313e..10760f72df0 100644
--- a/src/mongo/s/async_requests_sender.cpp
+++ b/src/mongo/s/async_requests_sender.cpp
@@ -53,7 +53,7 @@ namespace mongo {
namespace {
-// Maximum number of retries for network and replication notMaster errors (per host).
+// Maximum number of retries for network and replication NotPrimary errors (per host).
const int kMaxNumFailedHostRetryAttempts = 3;
} // namespace
diff --git a/src/mongo/s/catalog/dist_lock_catalog_impl.cpp b/src/mongo/s/catalog/dist_lock_catalog_impl.cpp
index d8574212532..9a6afad4de0 100644
--- a/src/mongo/s/catalog/dist_lock_catalog_impl.cpp
+++ b/src/mongo/s/catalog/dist_lock_catalog_impl.cpp
@@ -147,7 +147,7 @@ StatusWith<OID> extractElectionId(const BSONObj& responseObj) {
<< hostContacted};
}
- return {ErrorCodes::NotMaster, "only primary can have electionId"};
+ return {ErrorCodes::NotWritablePrimary, "only primary can have electionId"};
}
return {ErrorCodes::UnsupportedFormat, electionIdStatus.reason()};
diff --git a/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp b/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
index f660b5cf7da..3811550e376 100644
--- a/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
+++ b/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp
@@ -469,7 +469,7 @@ TEST_F(DistLockCatalogTest, GrabLockWriteConcernError) {
auto status = distLockCatalog()
->grabLock(operationContext(), "", OID::gen(), "", "", Date_t::now(), "")
.getStatus();
- ASSERT_EQUALS(ErrorCodes::NotMaster, status.code());
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, status.code());
ASSERT_FALSE(status.reason().empty());
});
@@ -1280,7 +1280,7 @@ TEST_F(DistLockCatalogTest, GetServerNoGLEStats) {
TEST_F(DistLockCatalogTest, GetServerNoElectionId) {
auto future = launchOnSeparateThread([this](OperationContext* opCtx) {
auto status = distLockCatalog()->getServerInfo(operationContext()).getStatus();
- ASSERT_EQUALS(ErrorCodes::NotMaster, status.code());
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, status.code());
ASSERT_FALSE(status.reason().empty());
});
diff --git a/src/mongo/s/catalog/replset_dist_lock_manager.cpp b/src/mongo/s/catalog/replset_dist_lock_manager.cpp
index 6542d071ac9..d83c8c68138 100644
--- a/src/mongo/s/catalog/replset_dist_lock_manager.cpp
+++ b/src/mongo/s/catalog/replset_dist_lock_manager.cpp
@@ -140,7 +140,7 @@ void ReplSetDistLockManager::doTask() {
auto opCtx = cc().makeOperationContext();
auto pingStatus = _catalog->ping(opCtx.get(), _processID, Date_t::now());
- if (!pingStatus.isOK() && pingStatus != ErrorCodes::NotMaster) {
+ if (!pingStatus.isOK() && pingStatus != ErrorCodes::NotWritablePrimary) {
warning() << "pinging failed for distributed lock pinger" << causedBy(pingStatus);
}
@@ -173,7 +173,7 @@ void ReplSetDistLockManager::doTask() {
warning() << "Failed to unlock lock with " << LocksType::lockID() << ": "
<< toUnlock.first << nameMessage << causedBy(unlockStatus);
// Queue another attempt, unless the problem was no longer being primary.
- if (unlockStatus != ErrorCodes::NotMaster) {
+ if (unlockStatus != ErrorCodes::NotWritablePrimary) {
queueUnlock(toUnlock.first, toUnlock.second);
}
} else {
@@ -217,7 +217,7 @@ StatusWith<bool> ReplSetDistLockManager::isLockExpired(OperationContext* opCtx,
Timer timer(_serviceContext->getTickSource());
auto serverInfoStatus = _catalog->getServerInfo(opCtx);
if (!serverInfoStatus.isOK()) {
- if (serverInfoStatus.getStatus() == ErrorCodes::NotMaster) {
+ if (serverInfoStatus.getStatus() == ErrorCodes::NotWritablePrimary) {
return false;
}
diff --git a/src/mongo/s/catalog/replset_dist_lock_manager_test.cpp b/src/mongo/s/catalog/replset_dist_lock_manager_test.cpp
index 516d396f67d..94e7e7fe9c3 100644
--- a/src/mongo/s/catalog/replset_dist_lock_manager_test.cpp
+++ b/src/mongo/s/catalog/replset_dist_lock_manager_test.cpp
@@ -1568,7 +1568,7 @@ TEST_F(ReplSetDistLockManagerFixture, CannotOvertakeIfElectionIdChanged) {
/**
* 1. Try to grab lock multiple times.
- * 2. For each attempt, attempting to check the ping document results in NotMaster error.
+ * 2. For each attempt, attempting to check the ping document results in NotWritablePrimary error.
* 3. All of the previous attempt should result in lock busy.
* 4. Try to grab lock again when the ping was not updated and lock expiration has elapsed.
*/
@@ -1617,7 +1617,7 @@ TEST_F(ReplSetDistLockManagerFixture, CannotOvertakeIfNoMaster) {
} else {
getMockCatalog()->expectGetServerInfo(
[&getServerInfoCallCount]() { getServerInfoCallCount++; },
- {ErrorCodes::NotMaster, "not master"});
+ {ErrorCodes::NotWritablePrimary, "not master"});
}
auto status = distLock()->lock(operationContext(), "bar", "", Milliseconds(0)).getStatus();
diff --git a/src/mongo/s/catalog/sharding_catalog_client.h b/src/mongo/s/catalog/sharding_catalog_client.h
index febbf82fe06..387abe26f91 100644
--- a/src/mongo/s/catalog/sharding_catalog_client.h
+++ b/src/mongo/s/catalog/sharding_catalog_client.h
@@ -338,7 +338,7 @@ public:
* Updates a single document in the specified namespace on the config server. The document must
* have an _id index. Must only be used for updates to the 'config' database.
*
- * This method retries the operation on NotMaster or network errors, so it should only be used
+ * This method retries the operation on NotPrimary or network errors, so it should only be used
* with modifications which are idempotent.
*
* Returns non-OK status if the command failed to run for some reason. If the command was
diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.h b/src/mongo/s/catalog/sharding_catalog_client_impl.h
index 2ebc0fe3377..6248ed53b7a 100644
--- a/src/mongo/s/catalog/sharding_catalog_client_impl.h
+++ b/src/mongo/s/catalog/sharding_catalog_client_impl.h
@@ -173,7 +173,7 @@ private:
* Updates a single document in the specified namespace on the config server. The document must
* have an _id index. Must only be used for updates to the 'config' database.
*
- * This method retries the operation on NotMaster or network errors, so it should only be used
+ * This method retries the operation on NotPrimary or network errors, so it should only be used
* with modifications which are idempotent.
*
* Returns non-OK status if the command failed to run for some reason. If the command was
diff --git a/src/mongo/s/catalog/sharding_catalog_test.cpp b/src/mongo/s/catalog/sharding_catalog_test.cpp
index f0a3ec47636..31c47c9ff65 100644
--- a/src/mongo/s/catalog/sharding_catalog_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_test.cpp
@@ -247,14 +247,15 @@ TEST_F(ShardingCatalogClientTest, GetDatabaseStaleSecondaryRetryNoPrimary) {
auto future = launchAsync([this] {
auto dbResult = catalogClient()->getDatabase(
operationContext(), "NonExistent", repl::ReadConcernLevel::kMajorityReadConcern);
- ASSERT_EQ(dbResult.getStatus(), ErrorCodes::NotMaster);
+ ASSERT_EQ(dbResult.getStatus(), ErrorCodes::NotWritablePrimary);
});
// Return empty result set as if the database wasn't found
onFindCommand([this, &testHost](const RemoteCommandRequest& request) {
ASSERT_EQUALS(testHost, request.target);
- // Make it so when it attempts to retarget and retry it will get a NotMaster error.
- configTargeter()->setFindHostReturnValue(Status(ErrorCodes::NotMaster, "no config master"));
+ // Make it so when it attempts to retarget and retry it will get a NotWritablePrimary error.
+ configTargeter()->setFindHostReturnValue(
+ Status(ErrorCodes::NotWritablePrimary, "no config master"));
return vector<BSONObj>{};
});
@@ -685,7 +686,7 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandRewriteWriteConce
future.default_timed_get();
}
-TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotMaster) {
+TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotWritablePrimary) {
configTargeter()->setFindHostReturnValue(HostAndPort("TestHost1"));
auto future = launchAsync([this] {
@@ -699,14 +700,14 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotMaster) {
ASSERT_FALSE(ok);
Status commandStatus = getStatusFromCommandResult(responseBuilder.obj());
- ASSERT_EQUALS(ErrorCodes::NotMaster, commandStatus);
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, commandStatus);
});
for (int i = 0; i < 3; ++i) {
onCommand([](const RemoteCommandRequest& request) {
BSONObjBuilder responseBuilder;
- CommandHelpers::appendCommandStatusNoThrow(responseBuilder,
- Status(ErrorCodes::NotMaster, "not master"));
+ CommandHelpers::appendCommandStatusNoThrow(
+ responseBuilder, Status(ErrorCodes::NotWritablePrimary, "not master"));
return responseBuilder.obj();
});
}
@@ -715,7 +716,7 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotMaster) {
future.default_timed_get();
}
-TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotMasterRetrySuccess) {
+TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotWritablePrimaryRetrySuccess) {
HostAndPort host1("TestHost1");
HostAndPort host2("TestHost2");
@@ -739,11 +740,11 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotMasterRetrySuc
ASSERT_EQUALS(host1, request.target);
BSONObjBuilder responseBuilder;
- CommandHelpers::appendCommandStatusNoThrow(responseBuilder,
- Status(ErrorCodes::NotMaster, "not master"));
+ CommandHelpers::appendCommandStatusNoThrow(
+ responseBuilder, Status(ErrorCodes::NotWritablePrimary, "not master"));
// Ensure that when the catalog manager tries to retarget after getting the
- // NotMaster response, it will get back a new target.
+ // NotWritablePrimary response, it will get back a new target.
configTargeter()->setFindHostReturnValue(host2);
return responseBuilder.obj();
});
diff --git a/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp b/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp
index 6ffc535bcb7..6b211599384 100644
--- a/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp
@@ -353,7 +353,7 @@ TEST_F(UpdateRetryTest, Success) {
future.default_timed_get();
}
-TEST_F(UpdateRetryTest, NotMasterErrorReturnedPersistently) {
+TEST_F(UpdateRetryTest, NotWritablePrimaryErrorReturnedPersistently) {
configTargeter()->setFindHostReturnValue(HostAndPort("TestHost1"));
BSONObj objToUpdate = BSON("_id" << 1 << "Value"
@@ -369,13 +369,14 @@ TEST_F(UpdateRetryTest, NotMasterErrorReturnedPersistently) {
updateExpr,
false,
ShardingCatalogClient::kMajorityWriteConcern);
- ASSERT_EQUALS(ErrorCodes::NotMaster, status);
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, status);
});
for (int i = 0; i < 3; ++i) {
onCommand([](const RemoteCommandRequest& request) {
BSONObjBuilder bb;
- CommandHelpers::appendCommandStatusNoThrow(bb, {ErrorCodes::NotMaster, "not master"});
+ CommandHelpers::appendCommandStatusNoThrow(
+ bb, {ErrorCodes::NotWritablePrimary, "not master"});
return bb.obj();
});
}
@@ -383,8 +384,8 @@ TEST_F(UpdateRetryTest, NotMasterErrorReturnedPersistently) {
future.default_timed_get();
}
-TEST_F(UpdateRetryTest, NotMasterReturnedFromTargeter) {
- configTargeter()->setFindHostReturnValue(Status(ErrorCodes::NotMaster, "not master"));
+TEST_F(UpdateRetryTest, NotWritablePrimaryReturnedFromTargeter) {
+ configTargeter()->setFindHostReturnValue(Status(ErrorCodes::NotWritablePrimary, "not master"));
BSONObj objToUpdate = BSON("_id" << 1 << "Value"
<< "TestValue");
@@ -399,13 +400,13 @@ TEST_F(UpdateRetryTest, NotMasterReturnedFromTargeter) {
updateExpr,
false,
ShardingCatalogClient::kMajorityWriteConcern);
- ASSERT_EQUALS(ErrorCodes::NotMaster, status);
+ ASSERT_EQUALS(ErrorCodes::NotWritablePrimary, status);
});
future.default_timed_get();
}
-TEST_F(UpdateRetryTest, NotMasterOnceSuccessAfterRetry) {
+TEST_F(UpdateRetryTest, NotWritablePrimaryOnceSuccessAfterRetry) {
HostAndPort host1("TestHost1");
HostAndPort host2("TestHost2");
configTargeter()->setFindHostReturnValue(host1);
@@ -436,11 +437,12 @@ TEST_F(UpdateRetryTest, NotMasterOnceSuccessAfterRetry) {
ASSERT_EQUALS(host1, request.target);
// Ensure that when the catalog manager tries to retarget after getting the
- // NotMaster response, it will get back a new target.
+ // NotWritablePrimary response, it will get back a new target.
configTargeter()->setFindHostReturnValue(host2);
BSONObjBuilder bb;
- CommandHelpers::appendCommandStatusNoThrow(bb, {ErrorCodes::NotMaster, "not master"});
+ CommandHelpers::appendCommandStatusNoThrow(bb,
+ {ErrorCodes::NotWritablePrimary, "not master"});
return bb.obj();
});
diff --git a/src/mongo/s/client/shard_registry.h b/src/mongo/s/client/shard_registry.h
index 2b9e839394f..e755e2cff0c 100644
--- a/src/mongo/s/client/shard_registry.h
+++ b/src/mongo/s/client/shard_registry.h
@@ -133,7 +133,7 @@ private:
/**
* Maintains the set of all shards known to the instance and their connections and exposes
* functionality to run commands against shards. All commands which this registry executes are
- * retried on NotMaster class of errors and in addition all read commands are retried on network
+ * retried on NotPrimary class of errors and in addition all read commands are retried on network
* errors automatically as well.
*/
class ShardRegistry {
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index 056c95f1306..3a4d3b8aa3f 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -51,7 +51,7 @@ const BSONObj AsyncResultsMerger::kWholeSortKeySortPattern = BSON(kSortKeyField
namespace {
-// Maximum number of retries for network and replication notMaster errors (per host).
+// Maximum number of retries for network and replication NotPrimary errors (per host).
const int kMaxNumFailedHostRetryAttempts = 3;
/**
diff --git a/src/mongo/s/write_ops/batch_downconvert.cpp b/src/mongo/s/write_ops/batch_downconvert.cpp
index 323af2928c1..8293d35ef57 100644
--- a/src/mongo/s/write_ops/batch_downconvert.cpp
+++ b/src/mongo/s/write_ops/batch_downconvert.cpp
@@ -82,7 +82,8 @@ Status extractGLEErrors(const BSONObj& gleResponse, GLEErrors* errors) {
|| code == 16805 /* replicatedToNum no longer primary */
|| code == 14830 /* gle wmode changed / invalid */
// 2.6 Error codes
- || code == ErrorCodes::NotMaster || code == ErrorCodes::UnknownReplWriteConcern ||
+ || code == ErrorCodes::NotWritablePrimary ||
+ code == ErrorCodes::UnknownReplWriteConcern ||
code == ErrorCodes::WriteConcernFailed || code == ErrorCodes::PrimarySteppedDown) {
// Write concern errors that get returned as regular errors (result may not be ok: 1.0)
errors->wcError.reset(new WriteConcernErrorDetail());
diff --git a/src/mongo/s/write_ops/batch_write_exec_test.cpp b/src/mongo/s/write_ops/batch_write_exec_test.cpp
index cbc00a2934e..811be15b961 100644
--- a/src/mongo/s/write_ops/batch_write_exec_test.cpp
+++ b/src/mongo/s/write_ops/batch_write_exec_test.cpp
@@ -1069,7 +1069,7 @@ TEST_F(BatchWriteExecTest, RetryableErrorNoTxnNumber) {
request.setWriteConcern(BSONObj());
BatchedCommandResponse retryableErrResponse;
- retryableErrResponse.setStatus({ErrorCodes::NotMaster, "mock retryable error"});
+ retryableErrResponse.setStatus({ErrorCodes::NotWritablePrimary, "mock retryable error"});
auto future = launchAsync([&] {
BatchedCommandResponse response;
@@ -1111,7 +1111,7 @@ TEST_F(BatchWriteExecTest, RetryableErrorTxnNumber) {
operationContext()->setTxnNumber(5);
BatchedCommandResponse retryableErrResponse;
- retryableErrResponse.setStatus({ErrorCodes::NotMaster, "mock retryable error"});
+ retryableErrResponse.setStatus({ErrorCodes::NotWritablePrimary, "mock retryable error"});
auto future = launchAsync([&] {
BatchedCommandResponse response;
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index ac7255f806b..31ddc54096e 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -95,7 +95,7 @@ function isRetryableError(error) {
"HostNotFound",
"NetworkTimeout",
"SocketException",
- "NotMaster",
+ "NotWritablePrimary",
"NotMasterNoSlaveOk",
"NotMasterOrSecondary",
"PrimarySteppedDown",
diff --git a/src/mongo/util/assert_util_test.cpp b/src/mongo/util/assert_util_test.cpp
index 754d747b5da..f4ee8fa0629 100644
--- a/src/mongo/util/assert_util_test.cpp
+++ b/src/mongo/util/assert_util_test.cpp
@@ -87,26 +87,29 @@ TEST(AssertUtils, UassertNamedCodeWithoutCategories) {
ASSERT_NOT_CATCHES(ErrorCodes::BadValue, ExceptionForCat<ErrorCategory::Interruption>);
}
-// NotMaster - NotMasterError, RetriableError
-MONGO_STATIC_ASSERT(std::is_same<error_details::ErrorCategoriesFor<ErrorCodes::NotMaster>,
+// NotWritablePrimary - NotMasterError, RetriableError
+MONGO_STATIC_ASSERT(std::is_same<error_details::ErrorCategoriesFor<ErrorCodes::NotWritablePrimary>,
error_details::CategoryList<ErrorCategory::NotMasterError,
ErrorCategory::RetriableError>>());
-MONGO_STATIC_ASSERT(std::is_base_of<AssertionException, ExceptionFor<ErrorCodes::NotMaster>>());
+MONGO_STATIC_ASSERT(
+ std::is_base_of<AssertionException, ExceptionFor<ErrorCodes::NotWritablePrimary>>());
MONGO_STATIC_ASSERT(!std::is_base_of<ExceptionForCat<ErrorCategory::NetworkError>,
- ExceptionFor<ErrorCodes::NotMaster>>());
+ ExceptionFor<ErrorCodes::NotWritablePrimary>>());
MONGO_STATIC_ASSERT(std::is_base_of<ExceptionForCat<ErrorCategory::NotMasterError>,
- ExceptionFor<ErrorCodes::NotMaster>>());
+ ExceptionFor<ErrorCodes::NotWritablePrimary>>());
MONGO_STATIC_ASSERT(!std::is_base_of<ExceptionForCat<ErrorCategory::Interruption>,
- ExceptionFor<ErrorCodes::NotMaster>>());
+ ExceptionFor<ErrorCodes::NotWritablePrimary>>());
TEST(AssertUtils, UassertNamedCodeWithOneCategory) {
- ASSERT_CATCHES(ErrorCodes::NotMaster, DBException);
- ASSERT_CATCHES(ErrorCodes::NotMaster, AssertionException);
- ASSERT_CATCHES(ErrorCodes::NotMaster, ExceptionFor<ErrorCodes::NotMaster>);
- ASSERT_NOT_CATCHES(ErrorCodes::NotMaster, ExceptionFor<ErrorCodes::DuplicateKey>);
- ASSERT_NOT_CATCHES(ErrorCodes::NotMaster, ExceptionForCat<ErrorCategory::NetworkError>);
- ASSERT_CATCHES(ErrorCodes::NotMaster, ExceptionForCat<ErrorCategory::NotMasterError>);
- ASSERT_NOT_CATCHES(ErrorCodes::NotMaster, ExceptionForCat<ErrorCategory::Interruption>);
+ ASSERT_CATCHES(ErrorCodes::NotWritablePrimary, DBException);
+ ASSERT_CATCHES(ErrorCodes::NotWritablePrimary, AssertionException);
+ ASSERT_CATCHES(ErrorCodes::NotWritablePrimary, ExceptionFor<ErrorCodes::NotWritablePrimary>);
+ ASSERT_NOT_CATCHES(ErrorCodes::NotWritablePrimary, ExceptionFor<ErrorCodes::DuplicateKey>);
+ ASSERT_NOT_CATCHES(ErrorCodes::NotWritablePrimary,
+ ExceptionForCat<ErrorCategory::NetworkError>);
+ ASSERT_CATCHES(ErrorCodes::NotWritablePrimary, ExceptionForCat<ErrorCategory::NotMasterError>);
+ ASSERT_NOT_CATCHES(ErrorCodes::NotWritablePrimary,
+ ExceptionForCat<ErrorCategory::Interruption>);
}
// InterruptedDueToReplStateChange - NotMasterError, Interruption, RetriableError