jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
/**
 * Tests that if the migration aborts before the recipient sets the rejectReadsBeforeTimestamp, the
 * recipient keeps rejecting all reads until the state doc is marked as garbage collectable.
 */
Tests that if the migration aborts before the recipient sets the rejectReadsBeforeTimestamp, the
recipient keeps rejecting all reads until the state doc is marked as garbage collectable.
Tests that if the migration aborts before the recipient sets the rejectReadsBeforeTimestamp the recipient keeps rejecting all reads until the state doc is marked as garbage collectable .
function testDoNotRejectReadsAfterMigrationAbortedBeforeReachingRejectReadsBeforeTimestamp(
    {testCase, dbName, collName, tenantMigrationTest}) {
    const tenantId = dbName.split('_')[0];
    const migrationOpts = {
        migrationIdString: extractUUIDFromObject(UUID()),
        tenantId,
    };
    const recipientRst = tenantMigrationTest.getRecipientRst();
    const recipientPrimary = recipientRst.getPrimary();
    let abortFp = configureFailPoint(recipientPrimary,
                                     "fpBeforeFulfillingDataConsistentPromise",
                                     {action: "stop", stopErrorCode: ErrorCodes.InternalError});
    TenantMigrationTest.assertAborted(
        tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
    abortFp.off();
    const nodes = testCase.isSupportedOnSecondaries ? recipientRst.nodes : [recipientPrimary];
    nodes.forEach(node => {
        const db = node.getDB(dbName);
        if (testCase.requiresReadTimestamp) {
            runCommand(
                db, testCase.command(collName, getLastOpTime(node).ts), ErrorCodes.SnapshotTooOld);
        } else {
            runCommand(db, testCase.command(collName), ErrorCodes.SnapshotTooOld);
        }
    });
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
    recipientRst.awaitReplication();
    nodes.forEach(node => {
        const db = node.getDB(dbName);
        if (testCase.requiresReadTimestamp) {
            runCommand(db, testCase.command(collName, getLastOpTime(node).ts), null);
        } else {
            runCommand(db, testCase.command(collName), null);
        }
    });
    tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
}
function testDoNotRejectReadsAfterMigrationAbortedBeforeReachingRejectReadsBeforeTimestamp ( { testCase , dbName , collName , tenantMigrationTest } ) { const tenantId = dbName . split ( '_' ) [ 0 ] ; const migrationOpts = { migrationIdString : extractUUIDFromObject ( UUID ( ) ) , tenantId , } ; const recipientRst = tenantMigrationTest . getRecipientRst ( ) ; const recipientPrimary = recipientRst . getPrimary ( ) ; let abortFp = configureFailPoint ( recipientPrimary , "fpBeforeFulfillingDataConsistentPromise" , { action : "stop" , stopErrorCode : ErrorCodes . InternalError } ) ; TenantMigrationTest . assertAborted ( tenantMigrationTest . runMigration ( migrationOpts , { automaticForgetMigration : false } ) ) ; abortFp . off ( ) ; const nodes = testCase . isSupportedOnSecondaries ? recipientRst . nodes : [ recipientPrimary ] ; nodes . forEach ( node => { const db = node . getDB ( dbName ) ; if ( testCase . requiresReadTimestamp ) { runCommand ( db , testCase . command ( collName , getLastOpTime ( node ) . ts ) , ErrorCodes . SnapshotTooOld ) ; } else { runCommand ( db , testCase . command ( collName ) , ErrorCodes . SnapshotTooOld ) ; } } ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationOpts . migrationIdString ) ) ; recipientRst . awaitReplication ( ) ; nodes . forEach ( node => { const db = node . getDB ( dbName ) ; if ( testCase . requiresReadTimestamp ) { runCommand ( db , testCase . command ( collName , getLastOpTime ( node ) . ts ) , null ) ; } else { runCommand ( db , testCase . command ( collName ) , null ) ; } } ) ; tenantMigrationTest . waitForMigrationGarbageCollection ( migrationOpts . migrationIdString ) ; }
Tests that if the migration aborts before the recipient sets the rejectReadsBeforeTimestamp, the
 recipient keeps rejecting all reads until the state doc is marked as garbage collectable.
Tests that if the migration aborts before the recipient sets the rejectReadsBeforeTimestamp the recipient keeps rejecting all reads until the state doc is marked as garbage collectable .
// Force the recipient to abort the migration right before it responds to the first // recipientSyncData (i.e. before it receives returnAfterReachingTimestamp in the second // recipientSyncData). // Wait for the write to mark the state doc as garbage collectable to be replicated to all // nodes.