jstests/sharding/internal_txns/libs/resharding_test.js
/*
     * Retries the commands specified inside 'testCase' as retryable writes. If this retry is
     * expected to fail, asserts that all commands fail with an IncompleteTransactionHistory error.
     */
Retries the commands specified inside 'testCase' as retryable writes. If this retry is
expected to fail, asserts that all commands fail with an IncompleteTransactionHistory error.
Retries the commands specified inside ' testCase ' as retryable writes . If this retry is expected to fail asserts that all commands fail with an IncompleteTransactionHistory error .
function runRetryableWriteOnRetry(testCase, expectRetryToSucceed) {
        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,
                expectRetryToSucceed: expectRetryToSucceed
            })} in a retryable write`);
        const lsid = testCase.parentLsid;
        const txnNumber = NumberLong(testCase.parentTxnNumber);
        for (let i = 0; i < testCase.commands.length; i++) {
            const command = testCase.commands[i];
            if (command.cmdObj.stmtId == -1) {
                continue;
            }
            const cmdObj = Object.assign({}, command.cmdObj, {lsid, txnNumber});
            const res = mongosConn.getDB(kDbName).runCommand(cmdObj);
            if (expectRetryToSucceed) {
                assert.commandWorked(res);
                command.checkResponseFunc(res);
            } else {
                assert.commandFailedWithCode(res, ErrorCodes.IncompleteTransactionHistory);
            }
        }
        testCase.checkDocsFunc(!testCase.abortOnInitialTry ||
                               expectRetryToSucceed );
    }
function runRetryableWriteOnRetry ( testCase , expectRetryToSucceed ) { jsTest . log ( ` ${ tojson ( { id : testCase . id , isPreparedTxn : testCase . isPreparedTxn , isLargeTxn : testCase . isLargeTxn , abortOnInitialTry : testCase . abortOnInitialTry , imageType : testCase . imageType , expectRetryToSucceed : expectRetryToSucceed } ) } ` ) ; const lsid = testCase . parentLsid ; const txnNumber = NumberLong ( testCase . parentTxnNumber ) ; for ( let i = 0 ; i < testCase . commands . length ; i ++ ) { const command = testCase . commands [ i ] ; if ( command . cmdObj . stmtId == - 1 ) { continue ; } const cmdObj = Object . assign ( { } , command . cmdObj , { lsid , txnNumber } ) ; const res = mongosConn . getDB ( kDbName ) . runCommand ( cmdObj ) ; if ( expectRetryToSucceed ) { assert . commandWorked ( res ) ; command . checkResponseFunc ( res ) ; } else { assert . commandFailedWithCode ( res , ErrorCodes . IncompleteTransactionHistory ) ; } } testCase . checkDocsFunc ( ! testCase . abortOnInitialTry || expectRetryToSucceed ) ; }
Retries the commands specified inside 'testCase' as retryable writes.
Retries the commands specified inside ' testCase ' as retryable writes .
// The statement in this command is not retryable so do not retry it. /* isTxnCommitted */