diff options
author | Mathias Stearn <mathias@10gen.com> | 2017-09-12 15:43:03 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2017-09-13 17:50:40 -0400 |
commit | c514e143a50cb2623078087f56144a05c1419e9f (patch) | |
tree | c1d60ccf5be5a368a08fd5fb1b3db7e18590631f /src/mongo/s | |
parent | 47db63707f8dd9c86691e04ded450e4044ff7467 (diff) | |
download | mongo-c514e143a50cb2623078087f56144a05c1419e9f.tar.gz |
SERVER-31069 Stop converting SendStaleConfig to RecvStaleConfig
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/client/parallel.cpp | 26 | ||||
-rw-r--r-- | src/mongo/s/client/parallel.h | 4 | ||||
-rw-r--r-- | src/mongo/s/client/version_manager.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_aggregate.cpp | 3 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_drop_cmd.cpp | 6 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_find_and_modify_cmd.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/commands/commands_public.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/commands/strategy.cpp | 3 | ||||
-rw-r--r-- | src/mongo/s/stale_exception.h | 61 |
9 files changed, 43 insertions, 73 deletions
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 |