jstests/replsets/transaction_table_oplog_replay.js
/**
 * Runs each command on the primary, awaits replication then asserts the secondary's transaction
 * collection has been updated to store the latest txnNumber and lastWriteOpTimeTs for each
 * sessionId.
 */
Runs each command on the primary, awaits replication then asserts the secondary's transaction
collection has been updated to store the latest txnNumber and lastWriteOpTimeTs for each
sessionId.
Runs each command on the primary awaits replication then asserts the secondary ' s transaction collection has been updated to store the latest txnNumber and lastWriteOpTimeTs for each sessionId .
function runCommandsWithDifferentIds(primary, secondary, cmds) {
    secondary.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "alwaysOn"});
    let responseTimestamps = [];
    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);
        responseTimestamps.push(opTime);
    });
    secondary.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "off"});
    replTest.awaitReplication();
    cmds.forEach(function(cmd, i) {
        RetryableWritesUtil.checkTransactionTable(
            secondary, cmd.lsid, cmd.txnNumber, responseTimestamps[i]);
    });
    cmds.forEach(function(cmd) {
        RetryableWritesUtil.assertSameRecordOnBothConnections(primary, secondary, cmd.lsid);
    });
}
function runCommandsWithDifferentIds ( primary , secondary , cmds ) { secondary . adminCommand ( { configureFailPoint : "rsSyncApplyStop" , mode : "alwaysOn" } ) ; let responseTimestamps = [ ] ; 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 ) ; responseTimestamps . push ( opTime ) ; } ) ; secondary . adminCommand ( { configureFailPoint : "rsSyncApplyStop" , mode : "off" } ) ; replTest . awaitReplication ( ) ; cmds . forEach ( function ( cmd , i ) { RetryableWritesUtil . checkTransactionTable ( secondary , cmd . lsid , cmd . txnNumber , responseTimestamps [ i ] ) ; } ) ; cmds . forEach ( function ( cmd ) { RetryableWritesUtil . assertSameRecordOnBothConnections ( primary , secondary , cmd . lsid ) ; } ) ; }
Runs each command on the primary, awaits replication then asserts the secondary's transaction
 collection has been updated to store the latest txnNumber and lastWriteOpTimeTs for each
 sessionId.
Runs each command on the primary awaits replication then asserts the secondary ' s transaction collection has been updated to store the latest txnNumber and lastWriteOpTimeTs for each sessionId .
// Disable oplog application to ensure the oplog entries come in the same batch. // After replication, assert the secondary's transaction table has been updated. // Both nodes should have the same transaction collection record for each sessionId.