summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s')
-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
13 files changed, 40 insertions, 36 deletions
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;