jstests/sharding/internal_txns/libs/resharding_test.js
/*
     * Runs the commands defined inside 'testCase' in an internal transaction of the specified
     * type.
     */
Runs the commands defined inside 'testCase' in an internal transaction of the specified
type.
Runs the commands defined inside ' testCase ' in an internal transaction of the specified type .
function runInternalTransactionOnInitialTry(txnType, testCase) {
        jsTest.log(`Running write statements in an internal transaction with options ${tojson({
            id: testCase.id,
            isPreparedTxn: testCase.isPreparedTxn,
            isLargeTxn: testCase.isLargeTxn,
            abortOnInitialTry: testCase.abortOnInitialTry,
            imageType: testCase.imageType
        })}`);
        testCase.setUpFunc();
        const lsid = getTransactionSessionId(txnType, testCase);
        while (true) {
            const txnNumber = getNextTxnNumber(txnType, testCase);
            try {
                for (let i = 0; i < testCase.commands.length; i++) {
                    const command = testCase.commands[i];
                    const cmdObj =
                        Object.assign({}, command.cmdObj, {lsid, txnNumber, autocommit: false});
                    if (i == 0) {
                        cmdObj.startTransaction = true;
                    }
                    const res = assert.commandWorked(mongosConn.getDB(kDbName).runCommand(cmdObj));
                    command.checkResponseFunc(res);
                }
                if (testCase.abortOnInitialTry) {
                    abortTransaction(lsid, txnNumber, testCase.isPreparedTxn);
                } else {
                    commitTransaction(lsid, txnNumber);
                }
                break;
            } catch (e) {
                if (e.hasOwnProperty('errorLabels') &&
                    e.errorLabels.includes('TransientTransactionError') &&
                    e.code != ErrorCodes.NoSuchTransaction) {
                    jsTest.log("Failed to run transaction due to a transient error " + tojson(e));
                } else {
                    throw e;
                }
            }
        }
        testCase.checkDocsFunc(!testCase.abortOnInitialTry );
    }
function runInternalTransactionOnInitialTry ( txnType , testCase ) { jsTest . log ( ` ${ tojson ( { id : testCase . id , isPreparedTxn : testCase . isPreparedTxn , isLargeTxn : testCase . isLargeTxn , abortOnInitialTry : testCase . abortOnInitialTry , imageType : testCase . imageType } ) } ` ) ; testCase . setUpFunc ( ) ; const lsid = getTransactionSessionId ( txnType , testCase ) ; while ( true ) { const txnNumber = getNextTxnNumber ( txnType , testCase ) ; try { for ( let i = 0 ; i < testCase . commands . length ; i ++ ) { const command = testCase . commands [ i ] ; const cmdObj = Object . assign ( { } , command . cmdObj , { lsid , txnNumber , autocommit : false } ) ; if ( i == 0 ) { cmdObj . startTransaction = true ; } const res = assert . commandWorked ( mongosConn . getDB ( kDbName ) . runCommand ( cmdObj ) ) ; command . checkResponseFunc ( res ) ; } if ( testCase . abortOnInitialTry ) { abortTransaction ( lsid , txnNumber , testCase . isPreparedTxn ) ; } else { commitTransaction ( lsid , txnNumber ) ; } break ; } catch ( e ) { if ( e . hasOwnProperty ( 'errorLabels' ) && e . errorLabels . includes ( 'TransientTransactionError' ) && e . code != ErrorCodes . NoSuchTransaction ) { jsTest . log ( "Failed to run transaction due to a transient error " + tojson ( e ) ) ; } else { throw e ; } } } testCase . checkDocsFunc ( ! testCase . abortOnInitialTry ) ; }
Runs the commands defined inside 'testCase' in an internal transaction of the specified
 type.
Runs the commands defined inside ' testCase ' in an internal transaction of the specified type .
/* isTxnCommitted */