summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/aggregation/shard_targeting.js10
-rw-r--r--jstests/sharding/safe_secondary_reads_drop_recreate.js6
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js4
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js4
-rw-r--r--jstests/sharding/secondary_shard_versioning.js4
-rw-r--r--src/mongo/base/error_codes.err6
-rw-r--r--src/mongo/client/dbclient.cpp10
-rw-r--r--src/mongo/client/dbclientcursor.cpp8
-rw-r--r--src/mongo/db/commands/dbcommands.cpp2
-rw-r--r--src/mongo/db/commands/eval.cpp2
-rw-r--r--src/mongo/db/commands/mr.cpp2
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp5
-rw-r--r--src/mongo/db/ops/write_ops_exec.h4
-rw-r--r--src/mongo/db/s/collection_sharding_state.cpp2
-rw-r--r--src/mongo/db/s/collection_sharding_state.h4
-rw-r--r--src/mongo/db/s/config/configsvr_drop_collection_command.cpp7
-rw-r--r--src/mongo/db/s/migration_source_manager.h2
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp23
-rw-r--r--src/mongo/rpc/legacy_reply_builder.cpp6
-rw-r--r--src/mongo/rpc/legacy_reply_builder.h2
-rw-r--r--src/mongo/s/client/parallel.cpp26
-rw-r--r--src/mongo/s/client/parallel.h4
-rw-r--r--src/mongo/s/client/version_manager.cpp4
-rw-r--r--src/mongo/s/commands/cluster_aggregate.cpp3
-rw-r--r--src/mongo/s/commands/cluster_drop_cmd.cpp6
-rw-r--r--src/mongo/s/commands/cluster_find_and_modify_cmd.cpp5
-rw-r--r--src/mongo/s/commands/commands_public.cpp4
-rw-r--r--src/mongo/s/commands/strategy.cpp3
-rw-r--r--src/mongo/s/stale_exception.h61
29 files changed, 95 insertions, 134 deletions
diff --git a/jstests/aggregation/shard_targeting.js b/jstests/aggregation/shard_targeting.js
index 7b33854f601..409eb636b61 100644
--- a/jstests/aggregation/shard_targeting.js
+++ b/jstests/aggregation/shard_targeting.js
@@ -68,12 +68,8 @@
assert.writeOK(mongosColl.insert({_id: 50}));
assert.writeOK(mongosColl.insert({_id: 150}));
- const shardExceptions = [
- ErrorCodes.RecvStaleConfig,
- ErrorCodes.SendStaleConfig,
- ErrorCodes.StaleShardVersion,
- ErrorCodes.StaleEpoch
- ];
+ const shardExceptions =
+ [ErrorCodes.StaleConfig, ErrorCodes.StaleShardVersion, ErrorCodes.StaleEpoch];
// Create an $_internalSplitPipeline stage that forces the merge to occur on the Primary shard.
const forcePrimaryMerge = [{$_internalSplitPipeline: {mergeType: "primaryShard"}}];
@@ -380,4 +376,4 @@
});
st.stop();
-})(); \ No newline at end of file
+})();
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js
index 9d2d58dd6d1..43f6c8974ba 100644
--- a/jstests/sharding/safe_secondary_reads_drop_recreate.js
+++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js
@@ -359,7 +359,7 @@
filter: Object.extend({
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
@@ -418,7 +418,7 @@
filter: Object.extend({
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
@@ -490,7 +490,7 @@
filter: Object.extend({
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
index 1a1e998a99e..f1b036997f4 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
@@ -486,7 +486,7 @@
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
"command.readConcern": {"$exists": false},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
@@ -500,7 +500,7 @@
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
"command.readConcern": {"$exists": false},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
index 41331d67bc7..763d95f7bd9 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
@@ -414,7 +414,7 @@
filter: Object.extend({
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
@@ -427,7 +427,7 @@
filter: Object.extend({
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
},
commandProfile)
});
diff --git a/jstests/sharding/secondary_shard_versioning.js b/jstests/sharding/secondary_shard_versioning.js
index 0beab7f83fd..8c20f31f894 100644
--- a/jstests/sharding/secondary_shard_versioning.js
+++ b/jstests/sharding/secondary_shard_versioning.js
@@ -56,7 +56,7 @@
"command.query": {x: 1},
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
}
});
@@ -70,7 +70,7 @@
"command.query": {x: 1},
"command.shardVersion": {"$exists": true},
"command.$readPreference": {"mode": "secondary"},
- "exceptionCode": ErrorCodes.SendStaleConfig
+ "exceptionCode": ErrorCodes.StaleConfig
}
});
diff --git a/src/mongo/base/error_codes.err b/src/mongo/base/error_codes.err
index 1d00e3ab011..5ee1bff461b 100644
--- a/src/mongo/base/error_codes.err
+++ b/src/mongo/base/error_codes.err
@@ -228,7 +228,7 @@ error_code("TransactionTooOld", 225)
# Non-sequential error codes (for compatibility only)
error_code("SocketException", 9001)
-error_code("RecvStaleConfig", 9996)
+error_code("OBSOLETE_RecvStaleConfig", 9996)
error_code("NotMaster", 10107)
error_code("CannotGrowDocumentInCappedNamespace", 10003)
error_code("DuplicateKey", 11000)
@@ -242,7 +242,7 @@ error_code("BackgroundOperationInProgressForNamespace", 12587);
error_code("NotMasterOrSecondary", 13436);
error_code("NotMasterNoSlaveOk", 13435);
error_code("ShardKeyTooBig", 13334);
-error_code("SendStaleConfig", 13388);
+error_code("StaleConfig", 13388);
error_code("DatabaseDifferCase", 13297);
error_code("OBSOLETE_PrepareConfigsFailed", 13104);
@@ -264,7 +264,7 @@ error_class("NotMasterError", [
"PrimarySteppedDown",
])
error_class("StaleShardingError",
- ["RecvStaleConfig", "SendStaleConfig", "StaleShardVersion", "StaleEpoch"])
+ ["StaleConfig", "StaleShardVersion", "StaleEpoch"])
error_class("WriteConcernError", ["WriteConcernFailed",
"WriteConcernLegacyOK",
"UnknownReplWriteConcern",
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp
index 71087890376..0ddec421a12 100644
--- a/src/mongo/client/dbclient.cpp
+++ b/src/mongo/client/dbclient.cpp
@@ -60,7 +60,7 @@
#include "mongo/rpc/metadata.h"
#include "mongo/rpc/metadata/client_metadata.h"
#include "mongo/rpc/reply_interface.h"
-#include "mongo/s/stale_exception.h" // for RecvStaleConfigException
+#include "mongo/s/stale_exception.h"
#include "mongo/stdx/functional.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
@@ -179,10 +179,8 @@ rpc::UniqueReply DBClientBase::parseCommandReplyMessage(const std::string& host,
uassertStatusOK(_metadataReader(opCtx, commandReply->getMetadata(), host));
}
- if (ErrorCodes::SendStaleConfig ==
- getStatusFromCommandResult(commandReply->getCommandReply())) {
- throw RecvStaleConfigException("stale config in runCommand",
- commandReply->getCommandReply());
+ if (ErrorCodes::StaleConfig == getStatusFromCommandResult(commandReply->getCommandReply())) {
+ throw StaleConfigException("stale config in runCommand", commandReply->getCommandReply());
}
return rpc::UniqueReply(replyMsg, std::move(commandReply));
@@ -665,7 +663,7 @@ void DBClientBase::findN(vector<BSONObj>& out,
if (c->hasResultFlag(ResultFlag_ShardConfigStale)) {
BSONObj error;
c->peekError(&error);
- throw RecvStaleConfigException("findN stale config", error);
+ throw StaleConfigException("findN stale config", error);
}
for (int i = 0; i < nToReturn; i++) {
diff --git a/src/mongo/client/dbclientcursor.cpp b/src/mongo/client/dbclientcursor.cpp
index 5821ddc760d..0a439f610fb 100644
--- a/src/mongo/client/dbclientcursor.cpp
+++ b/src/mongo/client/dbclientcursor.cpp
@@ -254,9 +254,9 @@ BSONObj DBClientCursor::commandDataReceived(const Message& reply) {
auto commandReply = _client->parseCommandReplyMessage(_client->getServerAddress(), reply);
auto commandStatus = getStatusFromCommandResult(commandReply->getCommandReply());
- if (ErrorCodes::SendStaleConfig == commandStatus) {
- throw RecvStaleConfigException("stale config in DBClientCursor::dataReceived()",
- commandReply->getCommandReply());
+ if (ErrorCodes::StaleConfig == commandStatus) {
+ throw StaleConfigException("stale config in DBClientCursor::dataReceived()",
+ commandReply->getCommandReply());
} else if (!commandStatus.isOK()) {
wasError = true;
}
@@ -342,7 +342,7 @@ void DBClientCursor::dataReceived(const Message& reply, bool& retry, string& hos
if (qr.getResultFlags() & ResultFlag_ShardConfigStale) {
BSONObj error;
verify(peekError(&error));
- throw RecvStaleConfigException(
+ throw StaleConfigException(
(string) "stale config on lazy receive" + causedBy(getErrField(error)), error);
}
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 4ca970661b4..791d851c376 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -745,7 +745,7 @@ public:
try {
// RELOCKED
ctx.reset(new AutoGetCollectionForReadCommand(opCtx, nss));
- } catch (const SendStaleConfigException& ex) {
+ } catch (const StaleConfigException& ex) {
LOG(1) << "chunk metadata changed during filemd5, will retarget and continue";
break;
}
diff --git a/src/mongo/db/commands/eval.cpp b/src/mongo/db/commands/eval.cpp
index 9abc1a285f2..68589d6b7b3 100644
--- a/src/mongo/db/commands/eval.cpp
+++ b/src/mongo/db/commands/eval.cpp
@@ -210,7 +210,7 @@ public:
} catch (const AssertionException& ex) {
// Convert a stale shardVersion error to a stronger error to prevent this node or the
// sending node from believing it needs to refresh its routing table.
- if (ex.code() == ErrorCodes::RecvStaleConfig) {
+ if (ex.code() == ErrorCodes::StaleConfig) {
uasserted(ErrorCodes::BadValue,
str::stream() << "can't use sharded collection from db.eval");
}
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index b0c53c4ef52..ba47f51674a 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -1654,7 +1654,7 @@ public:
errmsg = "there were emits but no data!";
return false;
}
- } catch (SendStaleConfigException& e) {
+ } catch (StaleConfigException& e) {
log() << "mr detected stale config, should retry" << redact(e);
throw e;
}
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index 1f92597211c..24dfef674a7 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -206,7 +206,7 @@ bool handleError(OperationContext* opCtx,
}
if (ErrorCodes::isStaleShardingError(ex.code())) {
- auto staleConfigException = dynamic_cast<const SendStaleConfigException*>(&ex);
+ auto staleConfigException = dynamic_cast<const StaleConfigException*>(&ex);
if (!staleConfigException) {
// We need to get extra info off of the SCE, but some common patterns can result in the
// exception being converted to a Status then rethrown as a AssertionException, losing
@@ -225,8 +225,7 @@ bool handleError(OperationContext* opCtx,
->onStaleShardVersion(opCtx, nss, staleConfigException->getVersionReceived())
.transitional_ignore();
}
- out->staleConfigException =
- stdx::make_unique<SendStaleConfigException>(*staleConfigException);
+ out->staleConfigException = stdx::make_unique<StaleConfigException>(*staleConfigException);
return false;
}
diff --git a/src/mongo/db/ops/write_ops_exec.h b/src/mongo/db/ops/write_ops_exec.h
index 7f8620e56db..7483b78a236 100644
--- a/src/mongo/db/ops/write_ops_exec.h
+++ b/src/mongo/db/ops/write_ops_exec.h
@@ -51,12 +51,12 @@ struct WriteResult {
std::vector<StatusWith<SingleWriteResult>> results;
/**
- * If non-null, the SendStaleConfigException that was encountered while processing the op after
+ * If non-null, the StaleConfigException that was encountered while processing the op after
* the last op reported in results. Processing always stops at the first SCE and nothing is
* placed in results for the op that triggered it. The whole exception is copied here because it
* contains additional data not included in the Status.
*/
- std::unique_ptr<SendStaleConfigException> staleConfigException;
+ std::unique_ptr<StaleConfigException> staleConfigException;
};
diff --git a/src/mongo/db/s/collection_sharding_state.cpp b/src/mongo/db/s/collection_sharding_state.cpp
index 833e0c33825..a5b6073205d 100644
--- a/src/mongo/db/s/collection_sharding_state.cpp
+++ b/src/mongo/db/s/collection_sharding_state.cpp
@@ -196,7 +196,7 @@ void CollectionShardingState::checkShardVersionOrThrow(OperationContext* opCtx)
ChunkVersion received;
ChunkVersion wanted;
if (!_checkShardVersionOk(opCtx, &errmsg, &received, &wanted)) {
- throw SendStaleConfigException(
+ throw StaleConfigException(
_nss.ns(),
str::stream() << "[" << _nss.ns() << "] shard version not ok: " << errmsg,
received,
diff --git a/src/mongo/db/s/collection_sharding_state.h b/src/mongo/db/s/collection_sharding_state.h
index c94b64aeef3..5aa44336f70 100644
--- a/src/mongo/db/s/collection_sharding_state.h
+++ b/src/mongo/db/s/collection_sharding_state.h
@@ -181,10 +181,10 @@ public:
/**
* Checks whether the shard version in the context is compatible with the shard version of the
- * collection locally and if not throws SendStaleConfigException populated with the expected and
+ * collection locally and if not throws StaleConfigException populated with the expected and
* actual versions.
*
- * Because SendStaleConfigException has special semantics in terms of how a sharded command's
+ * Because StaleConfigException has special semantics in terms of how a sharded command's
* response is constructed, this function should be the only means of checking for shard version
* match.
*/
diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
index 33b78b8c2ba..8ba21d92be0 100644
--- a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
@@ -125,10 +125,9 @@ private:
dropCommandBSON,
Shard::RetryPolicy::kIdempotent));
- // Special-case SendStaleVersion errors
- if (cmdDropResult.commandStatus == ErrorCodes::SendStaleConfig) {
- throw RecvStaleConfigException(
- str::stream() << "Stale config while dropping collection", cmdDropResult.response);
+ if (cmdDropResult.commandStatus == ErrorCodes::StaleConfig) {
+ throw StaleConfigException("Stale config while dropping collection",
+ cmdDropResult.response);
}
uassertStatusOK(cmdDropResult.commandStatus);
diff --git a/src/mongo/db/s/migration_source_manager.h b/src/mongo/db/s/migration_source_manager.h
index 793e3f091a5..0f90ac96f2b 100644
--- a/src/mongo/db/s/migration_source_manager.h
+++ b/src/mongo/db/s/migration_source_manager.h
@@ -80,7 +80,7 @@ public:
*
* May throw any exception. Known exceptions are:
* - InvalidOptions if the operation context is missing shard version
- * - SendStaleConfigException if the expected collection version does not match what we find it
+ * - StaleConfigException if the expected collection version does not match what we find it
* to be after acquiring the distributed lock.
*/
MigrationSourceManager(OperationContext* opCtx,
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 8261a3a20a3..ad74a5be211 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/service_entry_point_mongod.h"
+#include "mongo/base/checked_cast.h"
#include "mongo/db/audit.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/impersonation_session.h"
@@ -118,8 +119,8 @@ void generateLegacyQueryErrorResponse(const AssertionException* exception,
<< " ntoreturn:" << queryMessage.ntoreturn;
}
- const SendStaleConfigException* scex = (exception->code() == ErrorCodes::SendStaleConfig)
- ? static_cast<const SendStaleConfigException*>(exception)
+ const StaleConfigException* scex = (exception->code() == ErrorCodes::StaleConfig)
+ ? checked_cast<const StaleConfigException*>(exception)
: NULL;
BSONObjBuilder err;
@@ -171,10 +172,9 @@ void _generateErrorResponse(OperationContext* opCtx,
// so we need to reset it to a clean state just to be sure.
replyBuilder->reset();
- // We need to include some extra information for SendStaleConfig.
- if (exception.code() == ErrorCodes::SendStaleConfig) {
- const SendStaleConfigException& scex =
- static_cast<const SendStaleConfigException&>(exception);
+ // We need to include some extra information for StaleConfig.
+ if (exception.code() == ErrorCodes::StaleConfig) {
+ const StaleConfigException& scex = checked_cast<const StaleConfigException&>(exception);
replyBuilder->setCommandReply(scex.toStatus(),
BSON("ns" << scex.getns() << "vReceived"
<< BSONArray(scex.getVersionReceived().toBSON())
@@ -198,10 +198,9 @@ void _generateErrorResponse(OperationContext* opCtx,
// so we need to reset it to a clean state just to be sure.
replyBuilder->reset();
- // We need to include some extra information for SendStaleConfig.
- if (exception.code() == ErrorCodes::SendStaleConfig) {
- const SendStaleConfigException& scex =
- static_cast<const SendStaleConfigException&>(exception);
+ // We need to include some extra information for StaleConfig.
+ if (exception.code() == ErrorCodes::StaleConfig) {
+ const StaleConfigException& scex = checked_cast<const StaleConfigException&>(exception);
replyBuilder->setCommandReply(scex.toStatus(),
BSON("ns" << scex.getns() << "vReceived"
<< BSONArray(scex.getVersionReceived().toBSON())
@@ -702,7 +701,7 @@ void execCommandDatabase(OperationContext* opCtx,
}
} catch (const DBException& e) {
// If we got a stale config, wait in case the operation is stuck in a critical section
- if (e.code() == ErrorCodes::SendStaleConfig) {
+ if (e.code() == ErrorCodes::StaleConfig) {
auto sce = dynamic_cast<const StaleConfigException*>(&e);
invariant(sce); // do not upcasts from DBException created by uassert variants.
@@ -859,7 +858,7 @@ DbResponse receivedQuery(OperationContext* opCtx,
dbResponse.exhaustNS = runQuery(opCtx, q, nss, dbResponse.response);
} catch (const AssertionException& e) {
// If we got a stale config, wait in case the operation is stuck in a critical section
- if (!opCtx->getClient()->isInDirectClient() && e.code() == ErrorCodes::SendStaleConfig) {
+ if (!opCtx->getClient()->isInDirectClient() && e.code() == ErrorCodes::StaleConfig) {
auto& sce = static_cast<const StaleConfigException&>(e);
ShardingState::get(opCtx)
->onStaleShardVersion(opCtx, NamespaceString(sce.getns()), sce.getVersionReceived())
diff --git a/src/mongo/rpc/legacy_reply_builder.cpp b/src/mongo/rpc/legacy_reply_builder.cpp
index 84c412af644..1696ea42902 100644
--- a/src/mongo/rpc/legacy_reply_builder.cpp
+++ b/src/mongo/rpc/legacy_reply_builder.cpp
@@ -54,9 +54,9 @@ LegacyReplyBuilder::~LegacyReplyBuilder() {}
LegacyReplyBuilder& LegacyReplyBuilder::setCommandReply(Status nonOKStatus,
BSONObj extraErrorInfo) {
invariant(_state == State::kCommandReply);
- if (nonOKStatus == ErrorCodes::SendStaleConfig) {
+ if (nonOKStatus == ErrorCodes::StaleConfig) {
_staleConfigError = true;
- // Need to use the special $err format for SendStaleConfig errors to be backwards
+ // Need to use the special $err format for StaleConfig errors to be backwards
// compatible.
BSONObjBuilder err;
// $err must be the first field in object.
@@ -120,7 +120,7 @@ Message LegacyReplyBuilder::done() {
QueryResult::View qr = _builder.buf();
if (_staleConfigError) {
- // For compatibility with legacy mongos, we need to set this result flag on SendStaleConfig
+ // For compatibility with legacy mongos, we need to set this result flag on StaleConfig
qr.setResultFlags(ResultFlag_ErrSet | ResultFlag_ShardConfigStale);
} else {
qr.setResultFlagsToOk();
diff --git a/src/mongo/rpc/legacy_reply_builder.h b/src/mongo/rpc/legacy_reply_builder.h
index d72fdc6b93b..fba41aabdfe 100644
--- a/src/mongo/rpc/legacy_reply_builder.h
+++ b/src/mongo/rpc/legacy_reply_builder.h
@@ -48,7 +48,7 @@ public:
LegacyReplyBuilder(Message&&);
~LegacyReplyBuilder() final;
- // Override of setCommandReply specifically used to handle SendStaleConfigException.
+ // Override of setCommandReply specifically used to handle StaleConfigException.
LegacyReplyBuilder& setCommandReply(Status nonOKStatus, BSONObj extraErrorInfo) final;
LegacyReplyBuilder& setRawCommandReply(const BSONObj& commandReply) final;
diff --git a/src/mongo/s/client/parallel.cpp b/src/mongo/s/client/parallel.cpp
index 23594f586da..5ba651ec1b6 100644
--- a/src/mongo/s/client/parallel.cpp
+++ b/src/mongo/s/client/parallel.cpp
@@ -328,10 +328,10 @@ void ParallelSortClusteredCursor::_markStaleNS(const NamespaceString& staleNS,
const int tries = ++_staleNSMap[staleNS.ns()];
if (tries >= 5) {
- throw SendStaleConfigException(staleNS.ns(),
- "too many retries of stale version info",
- e.getVersionReceived(),
- e.getVersionWanted());
+ throw StaleConfigException(staleNS.ns(),
+ "too many retries of stale version info",
+ e.getVersionReceived(),
+ e.getVersionWanted());
}
}
@@ -764,7 +764,7 @@ void ParallelSortClusteredCursor::finishInit(OperationContext* opCtx) {
LOG(pc) << "finished on shard " << shardId << ", current connection state is "
<< mdata.toBSON();
}
- } catch (RecvStaleConfigException& e) {
+ } catch (StaleConfigException& e) {
retry = true;
string staleNS = e.getns();
@@ -999,10 +999,10 @@ void ParallelSortClusteredCursor::_oldInit() {
// Version is zero b/c this is deprecated codepath
staleConfigExs.push_back(str::stream()
<< "stale config detected for "
- << RecvStaleConfigException(_ns,
- "ParallelCursor::_init",
- ChunkVersion(0, 0, OID()),
- ChunkVersion(0, 0, OID()))
+ << StaleConfigException(_ns,
+ "ParallelCursor::_init",
+ ChunkVersion(0, 0, OID()),
+ ChunkVersion(0, 0, OID()))
.what()
<< errLoc);
break;
@@ -1157,7 +1157,7 @@ void ParallelSortClusteredCursor::_oldInit() {
if (throwException && staleConfigExs.size() > 0) {
// Version is zero b/c this is deprecated codepath
- throw RecvStaleConfigException(
+ throw StaleConfigException(
_ns, errMsg.str(), ChunkVersion(0, 0, OID()), ChunkVersion(0, 0, OID()));
} else if (throwException) {
throw DBException(14827, errMsg.str());
@@ -1341,7 +1341,7 @@ void throwCursorStale(DBClientCursor* cursor) {
if (cursor->hasResultFlag(ResultFlag_ShardConfigStale)) {
BSONObj error;
cursor->peekError(&error);
- throw RecvStaleConfigException("query returned a stale config error", error);
+ throw StaleConfigException("query returned a stale config error", error);
}
if (NamespaceString(cursor->getns()).isCommand()) {
@@ -1351,8 +1351,8 @@ void throwCursorStale(DBClientCursor* cursor) {
//
// TODO: Standardize stale config reporting.
BSONObj res = cursor->peekFirst();
- if (res.hasField("code") && res["code"].Number() == ErrorCodes::SendStaleConfig) {
- throw RecvStaleConfigException("command returned a stale config error", res);
+ if (res.hasField("code") && res["code"].Number() == ErrorCodes::StaleConfig) {
+ throw StaleConfigException("command returned a stale config error", res);
}
}
}
diff --git a/src/mongo/s/client/parallel.h b/src/mongo/s/client/parallel.h
index d1680f1e74f..3b97c373085 100644
--- a/src/mongo/s/client/parallel.h
+++ b/src/mongo/s/client/parallel.h
@@ -166,8 +166,8 @@ private:
};
/**
- * Throws a RecvStaleConfigException wrapping the stale error document in this cursor when the
- * ShardConfigStale flag is set or a command returns a ErrorCodes::SendStaleConfig error code.
+ * Throws a StaleConfigException wrapping the stale error document in this cursor when the
+ * ShardConfigStale flag is set or a command returns a ErrorCodes::StaleConfig error code.
*/
void throwCursorStale(DBClientCursor* cursor);
diff --git a/src/mongo/s/client/version_manager.cpp b/src/mongo/s/client/version_manager.cpp
index 7f97716f620..0b3195e3859 100644
--- a/src/mongo/s/client/version_manager.cpp
+++ b/src/mongo/s/client/version_manager.cpp
@@ -311,7 +311,7 @@ bool checkShardVersion(OperationContext* opCtx,
<< shard->getConnString().toString()
<< ")");
- throw SendStaleConfigException(ns, msg, refVersion, currentVersion);
+ throw StaleConfigException(ns, msg, refVersion, currentVersion);
}
} else if (refManager) {
string msg(str::stream() << "not sharded (" << (!manager ? string("<none>") : str::stream()
@@ -325,7 +325,7 @@ bool checkShardVersion(OperationContext* opCtx,
<< conn_in->getServerAddress()
<< ")");
- throw SendStaleConfigException(
+ throw StaleConfigException(
ns, msg, refManager->getVersion(shard->getId()), ChunkVersion::UNSHARDED());
}
diff --git a/src/mongo/s/commands/cluster_aggregate.cpp b/src/mongo/s/commands/cluster_aggregate.cpp
index 4e560824760..4c050b812ac 100644
--- a/src/mongo/s/commands/cluster_aggregate.cpp
+++ b/src/mongo/s/commands/cluster_aggregate.cpp
@@ -703,8 +703,7 @@ Status ClusterAggregate::aggPassthrough(OperationContext* opCtx,
Shard::RetryPolicy::kIdempotent));
if (ErrorCodes::isStaleShardingError(cmdResponse.commandStatus.code())) {
- throw RecvStaleConfigException("command failed because of stale config",
- cmdResponse.response);
+ throw StaleConfigException("command failed because of stale config", cmdResponse.response);
}
BSONObj result;
diff --git a/src/mongo/s/commands/cluster_drop_cmd.cpp b/src/mongo/s/commands/cluster_drop_cmd.cpp
index 109ba3f2458..2b3dc5f5fd4 100644
--- a/src/mongo/s/commands/cluster_drop_cmd.cpp
+++ b/src/mongo/s/commands/cluster_drop_cmd.cpp
@@ -138,9 +138,9 @@ private:
Shard::RetryPolicy::kIdempotent));
// Special-case SendStaleVersion errors
- if (cmdDropResult.commandStatus == ErrorCodes::SendStaleConfig) {
- throw RecvStaleConfigException(
- str::stream() << "Stale config while dropping collection", cmdDropResult.response);
+ if (cmdDropResult.commandStatus == ErrorCodes::StaleConfig) {
+ throw StaleConfigException(str::stream() << "Stale config while dropping collection",
+ cmdDropResult.response);
}
uassertStatusOK(cmdDropResult.commandStatus);
diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
index c56599ad383..4ba19ff2e06 100644
--- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
@@ -234,10 +234,9 @@ private:
conn->runCommand(nss.db().toString(), filterCommandRequestForPassthrough(cmdObj), res);
conn.done();
- // ErrorCodes::RecvStaleConfig is the code for RecvStaleConfigException.
- if (!ok && res.getIntField("code") == ErrorCodes::RecvStaleConfig) {
+ if (!ok && res.getIntField("code") == ErrorCodes::StaleConfig) {
// Command code traps this exception and re-runs
- throw RecvStaleConfigException("FindAndModify", res);
+ throw StaleConfigException("FindAndModify", res);
}
// First append the properly constructed writeConcernError. It will then be skipped
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp
index 2f0de73a3ba..c0c05398c0e 100644
--- a/src/mongo/s/commands/commands_public.cpp
+++ b/src/mongo/s/commands/commands_public.cpp
@@ -104,8 +104,8 @@ bool cursorCommandPassthrough(OperationContext* opCtx,
BSONObj response = cursor->nextSafe().getOwned();
conn.done();
Status status = getStatusFromCommandResult(response);
- if (ErrorCodes::SendStaleConfig == status || ErrorCodes::RecvStaleConfig == status) {
- throw RecvStaleConfigException("command failed because of stale config", response);
+ if (ErrorCodes::StaleConfig == status) {
+ throw StaleConfigException("command failed because of stale config", response);
}
if (!status.isOK()) {
return Command::appendCommandStatus(*out, status);
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 77945bcd652..b4739aff879 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -229,8 +229,7 @@ void execCommandClient(OperationContext* opCtx,
result.resetToEmpty();
const int code = e.code();
- // Codes for StaleConfigException
- if (code == ErrorCodes::RecvStaleConfig || code == ErrorCodes::SendStaleConfig) {
+ if (code == ErrorCodes::StaleConfig) {
throw;
}
diff --git a/src/mongo/s/stale_exception.h b/src/mongo/s/stale_exception.h
index 36f30c7fecb..c340656c550 100644
--- a/src/mongo/s/stale_exception.h
+++ b/src/mongo/s/stale_exception.h
@@ -38,39 +38,33 @@ namespace mongo {
/**
* Thrown whenever the config info for a given shard/chunk is out of date.
*/
-class StaleConfigException : public AssertionException {
+class StaleConfigException final : public AssertionException {
public:
StaleConfigException(const std::string& ns,
const std::string& raw,
- int code,
ChunkVersion received,
ChunkVersion wanted)
- : AssertionException(
- code,
- str::stream() << raw << " ( ns : " << ns << ", received : " << received.toString()
- << ", wanted : "
- << wanted.toString()
- << ", "
- << (code == ErrorCodes::SendStaleConfig ? "send" : "recv")
- << " )"),
+ : AssertionException(ErrorCodes::StaleConfig,
+ str::stream() << raw << " ( ns : " << ns << ", received : "
+ << received.toString()
+ << ", wanted : "
+ << wanted.toString()
+ << " )"),
_ns(ns),
_received(received),
_wanted(wanted) {}
/** Preferred if we're rebuilding this from a thrown exception */
- StaleConfigException(const std::string& raw, int code, const BSONObj& error)
- : AssertionException(
- code,
- str::stream() << raw << " ( ns : " << (error["ns"].type() == String
- ? error["ns"].String()
- : std::string("<unknown>"))
- << ", received : "
- << ChunkVersion::fromBSON(error, "vReceived").toString()
- << ", wanted : "
- << ChunkVersion::fromBSON(error, "vWanted").toString()
- << ", "
- << (code == ErrorCodes::SendStaleConfig ? "send" : "recv")
- << " )"),
+ StaleConfigException(const std::string& raw, const BSONObj& error)
+ : AssertionException(ErrorCodes::StaleConfig,
+ str::stream() << raw << " ( ns : " << (error["ns"].type() == String
+ ? error["ns"].String()
+ : std::string("<unknown>"))
+ << ", received : "
+ << ChunkVersion::fromBSON(error, "vReceived").toString()
+ << ", wanted : "
+ << ChunkVersion::fromBSON(error, "vWanted").toString()
+ << " )"),
// For legacy reasons, we may not always get a namespace here
_ns(error["ns"].type() == String ? error["ns"].String() : ""),
_received(ChunkVersion::fromBSON(error, "vReceived")),
@@ -111,25 +105,4 @@ private:
ChunkVersion _wanted;
};
-class SendStaleConfigException : public StaleConfigException {
-public:
- SendStaleConfigException(const std::string& ns,
- const std::string& raw,
- ChunkVersion received,
- ChunkVersion wanted)
- : StaleConfigException(ns, raw, ErrorCodes::SendStaleConfig, received, wanted) {}
-};
-
-class RecvStaleConfigException : public StaleConfigException {
-public:
- RecvStaleConfigException(const std::string& ns,
- const std::string& raw,
- ChunkVersion received,
- ChunkVersion wanted)
- : StaleConfigException(ns, raw, ErrorCodes::RecvStaleConfig, received, wanted) {}
-
- RecvStaleConfigException(const std::string& raw, const BSONObj& error)
- : StaleConfigException(raw, ErrorCodes::RecvStaleConfig, error) {}
-};
-
} // namespace mongo