jstests/replsets/transaction_table_oplog_replay.js
/**
 * Runs each command on the primary and tracks the highest txnNumber and lastWriteOpTimeTs, then
 * asserts the secondary's transaction collection document for the sessionId has been updated
 * correctly.
 */
Runs each command on the primary and tracks the highest txnNumber and lastWriteOpTimeTs, then
asserts the secondary's transaction collection document for the sessionId has been updated
correctly.
Runs each command on the primary and tracks the highest txnNumber and lastWriteOpTimeTs then asserts the secondary ' s transaction collection document for the sessionId has been updated correctly .
function runCommandsWithSameId(primary, secondary, cmds) {
    secondary.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "alwaysOn"});
    let latestOpTimeTs = Timestamp();
    let highestTxnNumber = NumberLong(-1);
    cmds.forEach(function(cmd) {
        let res = assert.commandWorked(primary.getDB("test").runCommand(cmd));
        let opTime = (res.opTime.ts ? res.opTime.ts : res.opTime);
        RetryableWritesUtil.checkTransactionTable(primary, cmd.lsid, cmd.txnNumber, opTime);
        latestOpTimeTs = opTime;
        highestTxnNumber = (cmd.txnNumber > highestTxnNumber ? cmd.txnNumber : highestTxnNumber);
    });
    secondary.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "off"});
    replTest.awaitReplication();
    RetryableWritesUtil.checkTransactionTable(
        secondary, cmds[0].lsid, highestTxnNumber, latestOpTimeTs);
    RetryableWritesUtil.assertSameRecordOnBothConnections(primary, secondary, cmds[0].lsid);
}
function runCommandsWithSameId ( primary , secondary , cmds ) { secondary . adminCommand ( { configureFailPoint : "rsSyncApplyStop" , mode : "alwaysOn" } ) ; let latestOpTimeTs = Timestamp ( ) ; let highestTxnNumber = NumberLong ( - 1 ) ; cmds . forEach ( function ( cmd ) { let res = assert . commandWorked ( primary . getDB ( "test" ) . runCommand ( cmd ) ) ; let opTime = ( res . opTime . ts ? res . opTime . ts : res . opTime ) ; RetryableWritesUtil . checkTransactionTable ( primary , cmd . lsid , cmd . txnNumber , opTime ) ; latestOpTimeTs = opTime ; highestTxnNumber = ( cmd . txnNumber > highestTxnNumber ? cmd . txnNumber : highestTxnNumber ) ; } ) ; secondary . adminCommand ( { configureFailPoint : "rsSyncApplyStop" , mode : "off" } ) ; replTest . awaitReplication ( ) ; RetryableWritesUtil . checkTransactionTable ( secondary , cmds [ 0 ] . lsid , highestTxnNumber , latestOpTimeTs ) ; RetryableWritesUtil . assertSameRecordOnBothConnections ( primary , secondary , cmds [ 0 ] . lsid ) ; }
Runs each command on the primary and tracks the highest txnNumber and lastWriteOpTimeTs, then
 asserts the secondary's transaction collection document for the sessionId has been updated
 correctly.
Runs each command on the primary and tracks the highest txnNumber and lastWriteOpTimeTs then asserts the secondary ' s transaction collection document for the sessionId has been updated correctly .
// Disable oplog application to ensure the oplog entries come in the same batch. // After replication, assert the secondary's transaction table has been updated to store the // highest transaction number and the latest write optime. // Both nodes should have the same transaction collection record for the sessionId.