diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-11-12 16:20:11 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-11-16 18:04:24 -0500 |
commit | 10872ad8758b99a266c0340b88cd81f20b89bdf7 (patch) | |
tree | b2aef171852486385a39326fd3cdfc63dbfccb9a /src/mongo/s/client/shard_registry.h | |
parent | bd58ea2ba5d17b960981990bb97cab133d7e90ed (diff) | |
download | mongo-10872ad8758b99a266c0340b88cd81f20b89bdf7.tar.gz |
SERVER-21392 Make commands retry on interrupted operations
Diffstat (limited to 'src/mongo/s/client/shard_registry.h')
-rw-r--r-- | src/mongo/s/client/shard_registry.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/mongo/s/client/shard_registry.h b/src/mongo/s/client/shard_registry.h index 3f83a49f764..c99a496883b 100644 --- a/src/mongo/s/client/shard_registry.h +++ b/src/mongo/s/client/shard_registry.h @@ -278,26 +278,23 @@ public: const std::string& dbname, const BSONObj& cmdObj); - StatusWith<BSONObj> runCommandOnConfigWithNotMasterRetries(OperationContext* txn, - const std::string& dbname, - const BSONObj& cmdObj); - class ErrorCodesHash { public: size_t operator()(ErrorCodes::Error e) const { return std::hash<typename std::underlying_type<ErrorCodes::Error>::type>()(e); } }; + using ErrorCodesSet = unordered_set<ErrorCodes::Error, ErrorCodesHash>; /** - * Runs commands against a config shard. Retries if executing the command fails with one - * of the given error codes, or if executing the command succeeds but the command - * failed with one of the codes. If executing the command fails with a different - * code we return that code. If executing the command succeeds and the command - * itself succeeds or fails with a code not in the set, then we return the command response - * object. Thus the caller is responsible for checking the command response object for any kind - * of command-specific failures other than those specified in errorsToCheck. + * Runs commands against the config shard's primary. Retries if executing the command fails with + * one of the given error codes, or if executing the command succeeds but the server returned + * one of the codes. If executing the command fails with a different code we return that code. + * If executing the command succeeds and the command itself succeeds or fails with a code not in + * the set, then we return the command response object. Thus the caller is responsible for + * checking the command response object for any kind of command-specific failures other than + * those specified in errorsToCheck. */ StatusWith<BSONObj> runCommandOnConfigWithRetries(OperationContext* txn, const std::string& dbname, @@ -312,6 +309,18 @@ public: const HostAndPort& remoteHost, const Status& remoteCommandStatus); + /** + * Set of error codes, which indicate that the remote host is not the current master. Retries on + * errors from this set are always safe and should be used by default. + */ + static const ErrorCodesSet kNotMasterErrors; + + /** + * Set of error codes which includes NotMaster and any network exceptions. Retries on errors + * from this set are not always safe and may require some additional idempotency guarantees. + */ + static const ErrorCodesSet kNetworkOrNotMasterErrors; + private: using ShardMap = std::unordered_map<ShardId, std::shared_ptr<Shard>>; |