jstests/replsets/tenant_migration_donor_abort_state_transition.js
/**
 * Starts a migration and forces the write to insert the donor's state doc to abort on the first few
 * tries. Asserts that the migration still completes successfully.
 */
Starts a migration and forces the write to insert the donor's state doc to abort on the first few
tries. Asserts that the migration still completes successfully.
Starts a migration and forces the write to insert the donor ' s state doc to abort on the first few tries . Asserts that the migration still completes successfully .
function testAbortInitialState() {
    const tenantMigrationTest = new TenantMigrationTest({
        name: jsTestName(),
        quickGarbageCollection: true,
    });
    const donorRst = tenantMigrationTest.getDonorRst();
    const donorPrimary = donorRst.getPrimary();
    let writeConflictFp = configureFailPoint(donorPrimary, "WTWriteConflictException");
    const tenantId = `${kTenantIdPrefix}-initial`;
    const migrationId = UUID();
    const migrationOpts = {
        migrationIdString: extractUUIDFromObject(migrationId),
        tenantId,
        recipientConnString: tenantMigrationTest.getRecipientConnString(),
    };
    const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
    let migrationThread =
        new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
    migrationThread.start();
    writeConflictFp.wait();
    let opObserverFp = configureFailPoint(donorPrimary, "donorOpObserverFailAfterOnInsert");
    writeConflictFp.off();
    opObserverFp.wait();
    opObserverFp.off();
    TenantMigrationTest.assertCommitted(migrationThread.returnData());
    tenantMigrationTest.waitForDonorNodesToReachState(
        donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kCommitted);
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
    tenantMigrationTest.stop();
}
function testAbortInitialState ( ) { const tenantMigrationTest = new TenantMigrationTest ( { name : jsTestName ( ) , quickGarbageCollection : true , } ) ; const donorRst = tenantMigrationTest . getDonorRst ( ) ; const donorPrimary = donorRst . getPrimary ( ) ; let writeConflictFp = configureFailPoint ( donorPrimary , "WTWriteConflictException" ) ; const tenantId = ` ${ kTenantIdPrefix } ` ; const migrationId = UUID ( ) ; const migrationOpts = { migrationIdString : extractUUIDFromObject ( migrationId ) , tenantId , recipientConnString : tenantMigrationTest . getRecipientConnString ( ) , } ; const donorRstArgs = TenantMigrationUtil . createRstArgs ( donorRst ) ; let migrationThread = new Thread ( TenantMigrationUtil . runMigrationAsync , migrationOpts , donorRstArgs ) ; migrationThread . start ( ) ; writeConflictFp . wait ( ) ; let opObserverFp = configureFailPoint ( donorPrimary , "donorOpObserverFailAfterOnInsert" ) ; writeConflictFp . off ( ) ; opObserverFp . wait ( ) ; opObserverFp . off ( ) ; TenantMigrationTest . assertCommitted ( migrationThread . returnData ( ) ) ; tenantMigrationTest . waitForDonorNodesToReachState ( donorRst . nodes , migrationId , tenantId , TenantMigrationTest . DonorState . kCommitted ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationOpts . migrationIdString ) ) ; tenantMigrationTest . stop ( ) ; }
Starts a migration and forces the write to insert the donor's state doc to abort on the first few
 tries.
Starts a migration and forces the write to insert the donor ' s state doc to abort on the first few tries .
// Force the storage transaction for the insert to abort prior to inserting the WiredTiger // record. // Run the migration in its own thread, since the initial 'donorStartMigration' command will // hang due to the failpoint. // Next, force the storage transaction for the insert to abort after inserting the WiredTiger // record and initializing the in-memory migration state. // Verify that the migration completes successfully.