jstests/sharding/internal_txns/libs/chunk_migration_test.js
/*
     * Retries the commands defined inside 'testCase' in an internal transaction of the specified
     * type.
     */
Retries the commands defined inside 'testCase' in an internal transaction of the specified
type.
Retries the commands defined inside ' testCase ' in an internal transaction of the specified type .
function runInternalTransactionOnRetry(txnType, testCase, isRetryAfterAbort) {
        jsTest.log(
            `Retrying write statements executed in an internal transaction with options ${tojson({
                id: testCase.id,
                isPreparedTxn: testCase.isPreparedTxn,
                isLargeTxn: testCase.isLargeTxn,
                abortOnInitialTry: testCase.abortOnInitialTry,
                imageType: testCase.imageType,
                isRetryAfterAbort: isRetryAfterAbort,
            })} in another internal transaction`);
        const lsid = getTransactionSessionId(txnType, testCase);
        lsid.txnUUID = UUID();
        const txnNumber = getNextTxnNumber(txnType, testCase);
        for (let i = 0; i < testCase.commands.length; i++) {
            const command = testCase.commands[i];
            if (!isRetryAfterAbort && command.cmdObj.stmtId == -1) {
                continue;
            }
            const cmdObj = Object.assign({}, command.cmdObj, {lsid, txnNumber, autocommit: false});
            if (i == 0) {
                cmdObj.startTransaction = true;
            }
            const res = assert.commandWorked(st.s.getDB(testCase.dbName).runCommand(cmdObj));
            command.checkResponseFunc(res);
        }
        commitTransaction(lsid, txnNumber);
        testCase.checkDocsFunc(true );
    }
function runInternalTransactionOnRetry ( txnType , testCase , isRetryAfterAbort ) { jsTest . log ( ` ${ tojson ( { id : testCase . id , isPreparedTxn : testCase . isPreparedTxn , isLargeTxn : testCase . isLargeTxn , abortOnInitialTry : testCase . abortOnInitialTry , imageType : testCase . imageType , isRetryAfterAbort : isRetryAfterAbort , } ) } ` ) ; const lsid = getTransactionSessionId ( txnType , testCase ) ; lsid . txnUUID = UUID ( ) ; const txnNumber = getNextTxnNumber ( txnType , testCase ) ; for ( let i = 0 ; i < testCase . commands . length ; i ++ ) { const command = testCase . commands [ i ] ; if ( ! isRetryAfterAbort && command . cmdObj . stmtId == - 1 ) { continue ; } const cmdObj = Object . assign ( { } , command . cmdObj , { lsid , txnNumber , autocommit : false } ) ; if ( i == 0 ) { cmdObj . startTransaction = true ; } const res = assert . commandWorked ( st . s . getDB ( testCase . dbName ) . runCommand ( cmdObj ) ) ; command . checkResponseFunc ( res ) ; } commitTransaction ( lsid , txnNumber ) ; testCase . checkDocsFunc ( true ) ; }
Retries the commands defined inside 'testCase' in an internal transaction of the specified
 type.
Retries the commands defined inside ' testCase ' in an internal transaction of the specified type .
// Give the session a different txnUUID to simulate a retry from a different mongos. // The transaction has already committed and the statement in this command // is not retryable so do not retry it. /* isTxnCommitted */