jstests/libs/override_methods/network_error_and_txn_override.js
// Returns the last command response received by a command or retry.
Returns the last command response received by a command or retry.
Returns the last command response received by a command or retry .
function retryWithTxnOverride(res, conn, dbName, cmdName, cmdObj, lsid, logError) {
    assert(configuredForTxnOverride());
    const failedOnCRUDStatement =
        hasError(res) && !isCommitOrAbort(cmdName) && isCmdInTransaction(cmdObj);
    if (failedOnCRUDStatement) {
        assert.gt(ops.length, 0);
        abortTransaction(conn, lsid, txnOptions.txnNumber);
        if (configuredForNetworkRetry() && RetryableWritesUtil.isRetryableCode(res.code)) {
            logError("Retrying on retryable error for transaction statement");
            return retryEntireTransaction(conn, lsid);
        }
    }
    if (TransactionsUtil.isTransientTransactionError(res) && cmdName !== "abortTransaction") {
        logError("Retrying on TransientTransactionError response");
        res = retryEntireTransaction(conn, lsid);
        if (!hasError(res) && cmdName === "commitTransaction") {
            commitTransaction(conn, lsid, txnOptions.txnNumber);
        }
        return res;
    }
    return res;
}
function retryWithTxnOverride ( res , conn , dbName , cmdName , cmdObj , lsid , logError ) { assert ( configuredForTxnOverride ( ) ) ; const failedOnCRUDStatement = hasError ( res ) && ! isCommitOrAbort ( cmdName ) && isCmdInTransaction ( cmdObj ) ; if ( failedOnCRUDStatement ) { assert . gt ( ops . length , 0 ) ; abortTransaction ( conn , lsid , txnOptions . txnNumber ) ; if ( configuredForNetworkRetry ( ) && RetryableWritesUtil . isRetryableCode ( res . code ) ) { logError ( "Retrying on retryable error for transaction statement" ) ; return retryEntireTransaction ( conn , lsid ) ; } } if ( TransactionsUtil . isTransientTransactionError ( res ) && cmdName !== "abortTransaction" ) { logError ( "Retrying on TransientTransactionError response" ) ; res = retryEntireTransaction ( conn , lsid ) ; if ( ! hasError ( res ) && cmdName === "commitTransaction" ) { commitTransaction ( conn , lsid , txnOptions . txnNumber ) ; } return res ; } return res ; }
Returns the last command response received by a command or retry.
Returns the last command response received by a command or retry .
// Transaction statements cannot be retried, but retryable codes are expected to succeed // on full transaction retry. // Transient transaction errors should retry the entire transaction. A // TransientTransactionError on "abortTransaction" is considered a success. // If we got a TransientTransactionError on 'commitTransaction' retrying the transaction // will not retry it, so we retry it here.