jstests/libs/override_methods/network_error_and_txn_override.js
// which case parent retries are completed early.
which case parent retries are completed early.
which case parent retries are completed early .
function retryEntireTransaction(conn, lsid) {
    assert.gt(ops.length, 0);
    const retriedTxnNumber = startNewTransaction(conn, {"ignored object": 1});
    logMsgFull('Retrying entire transaction',
               `txnNumber: ${retriedTxnNumber}, lsid: ${tojsononeline(lsid)}`);
    let res;
    for (let op of ops) {
        logMsgFull('Retrying op',
                   `txnNumber: ${retriedTxnNumber}, lsid: ${tojsononeline(lsid)},` +
                       ` db: ${op.dbName}, op: ${tojsononeline(op.cmdObj)}`);
        res = conn.getDB(op.dbName).runCommand(op.cmdObj);
        if (hasError(res) || hasWriteConcernError(res)) {
            return res;
        }
        assert.commandWorked(res);
        if (txnOptions.txnNumber !== retriedTxnNumber) {
            return res;
        }
    }
    return res;
}
function retryEntireTransaction ( conn , lsid ) { assert . gt ( ops . length , 0 ) ; const retriedTxnNumber = startNewTransaction ( conn , { "ignored object" : 1 } ) ; logMsgFull ( 'Retrying entire transaction' , ` ${ retriedTxnNumber } ${ tojsononeline ( lsid ) } ` ) ; let res ; for ( let op of ops ) { logMsgFull ( 'Retrying op' , ` ${ retriedTxnNumber } ${ tojsononeline ( lsid ) } ` + ` ${ op . dbName } ${ tojsononeline ( op . cmdObj ) } ` ) ; res = conn . getDB ( op . dbName ) . runCommand ( op . cmdObj ) ; if ( hasError ( res ) || hasWriteConcernError ( res ) ) { return res ; } assert . commandWorked ( res ) ; if ( txnOptions . txnNumber !== retriedTxnNumber ) { return res ; } } return res ; }
which case parent retries are completed early.
which case parent retries are completed early .
// Re-run every command in the ops array. // Keep track of what txnNumber this retry is attempting. // Running the command on conn will reenter from the top of `runCommandOverride`, // individual statement retries will be suppressed by tracking nesting level. // Sanity check that we checked for an error correctly. // If we recursively retried the entire transaction, we do not want to continue this // retry. We just pass up the response from the retry that completed. // We do not commit the transaction and let it continue in the next operation.