diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2019-04-23 15:44:56 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2019-04-25 17:56:55 -0400 |
commit | 0e9564888a31af6b49afb7a6106301bc16ae6956 (patch) | |
tree | f84473ba48a1ba050b05a7747443a0fce4182150 /src/mongo/db/handle_request_response.cpp | |
parent | 4b7ecadd7d1661f7d347d9bf990709b26cb539c4 (diff) | |
download | mongo-0e9564888a31af6b49afb7a6106301bc16ae6956.tar.gz |
SERVER-40446 Add "NonResumableChangeStreamError" error label
Give the "NonRetryableChangeStreamError" error class a more
appropriate name and propagate it to an "errorLabel" in the command
response.
Diffstat (limited to 'src/mongo/db/handle_request_response.cpp')
-rw-r--r-- | src/mongo/db/handle_request_response.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mongo/db/handle_request_response.cpp b/src/mongo/db/handle_request_response.cpp index 062075b82db..6628c60e8bc 100644 --- a/src/mongo/db/handle_request_response.cpp +++ b/src/mongo/db/handle_request_response.cpp @@ -36,23 +36,26 @@ BSONObj getErrorLabels(const OperationSessionInfoFromClient& sessionOptions, const std::string& commandName, ErrorCodes::Error code, bool hasWriteConcernError) { + BSONArrayBuilder labelArray; - // By specifying "autocommit", the user indicates they want to run a transaction. - // It is always false when set. - if (!sessionOptions.getAutocommit()) { - return {}; + // Note that we only apply the TransientTxnError label if the "autocommit" field is present in + // the session options. When present, "autocommit" will always be false, so we don't check its + // value. + if (sessionOptions.getAutocommit() && + isTransientTransactionError(code, + hasWriteConcernError, + commandName == "commitTransaction" || + commandName == "coordinateCommitTransaction")) { + // An error code for which isTransientTransactionError() is true indicates a transaction + // failure with no persistent side effects. + labelArray << txn::TransientTxnErrorFieldName; } - // The errors that indicate the transaction fails without any persistent side-effect. - bool isTransient = isTransientTransactionError( - code, - hasWriteConcernError, - commandName == "commitTransaction" || commandName == "coordinateCommitTransaction"); - - if (isTransient) { - return BSON("errorLabels" << BSON_ARRAY(txn::TransientTxnErrorFieldName)); + if (ErrorCodes::isNonResumableChangeStreamError(code)) { + labelArray << "NonResumableChangeStreamError"; } - return {}; + + return (labelArray.arrSize() > 0) ? BSON("errorLabels" << labelArray.arr()) : BSONObj(); } } // namespace mongo |