jstests/libs/override_methods/network_error_and_txn_override.js
// Top level runCommand override function.
Top level runCommand override function.
Top level runCommand override function .
function runCommandOverride(conn, dbName, cmdName, cmdObj, clientFunction, makeFuncArgs) {
    currentCommandID.push(newestCommandID++);
    nestingLevel++;
    if (cmdName === "query" || cmdName === "$query") {
        cmdObj = cmdObj[cmdName];
        cmdName = Object.keys(cmdObj)[0];
    }
    const lsid = cmdObj.lsid;
    try {
        const res = runCommandOverrideBody(
            conn, dbName, cmdName, cmdObj, lsid, clientFunction, makeFuncArgs);
        if (configuredForTxnOverride() && !isNested() && hasError(res) && (ops.length > 0)) {
            logMsgFull("Clearing ops on failed command",
                       `res: ${tojsononeline(res)}, cmd: ${tojsononeline(cmdObj)}`);
            clearOpsList();
            abortTransaction(conn, lsid, txnOptions.txnNumber);
        }
        return res;
    } finally {
        nestingLevel--;
        currentCommandID.pop();
        inCommandNetworkErrorRetry = false;
    }
}
function runCommandOverride ( conn , dbName , cmdName , cmdObj , clientFunction , makeFuncArgs ) { currentCommandID . push ( newestCommandID ++ ) ; nestingLevel ++ ; if ( cmdName === "query" || cmdName === "$query" ) { cmdObj = cmdObj [ cmdName ] ; cmdName = Object . keys ( cmdObj ) [ 0 ] ; } const lsid = cmdObj . lsid ; try { const res = runCommandOverrideBody ( conn , dbName , cmdName , cmdObj , lsid , clientFunction , makeFuncArgs ) ; if ( configuredForTxnOverride ( ) && ! isNested ( ) && hasError ( res ) && ( ops . length > 0 ) ) { logMsgFull ( "Clearing ops on failed command" , ` ${ tojsononeline ( res ) } ${ tojsononeline ( cmdObj ) } ` ) ; clearOpsList ( ) ; abortTransaction ( conn , lsid , txnOptions . txnNumber ) ; } return res ; } finally { nestingLevel -- ; currentCommandID . pop ( ) ; inCommandNetworkErrorRetry = false ; } }
Top level runCommand override function.
Top level runCommand override function .
// If the command is in a wrapped form, then we look for the actual command object // inside the query/$query object. // Many tests run queries that are expected to fail. In this case, when we wrap CRUD ops // in transactions, the transaction including the failed query will not be able to // commit. This override expects transactions to be able to commit. Rather than // denylisting all tests containing queries that are expected to fail, we clear the ops // list when we return an error to the test so we do not retry the failed query. // Reset recursion and retry state tracking.