jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
/**
 * Tests that in the blocking state, the donor blocks reads with atClusterTime/afterClusterTime >=
 * blockTimestamp but does not block linearizable reads.
 */
Tests that in the blocking state, the donor blocks reads with atClusterTime/afterClusterTime >
blockTimestamp but does not block linearizable reads.
Tests that in the blocking state the donor blocks reads with atClusterTime / afterClusterTime > blockTimestamp but does not block linearizable reads .
function testBlockReadsAfterMigrationEnteredBlocking(testCase, dbName, collName) {
    const tenantId = dbName.split('_')[0];
    const migrationIdString = extractUUIDFromObject(UUID());
    const migrationOpts = {
        migrationIdString,
        tenantId,
    };
    const donorRst = tenantMigrationTest.getDonorRst();
    const donorPrimary = donorRst.getPrimary();
    let blockingFp =
        configureFailPoint(donorPrimary, "pauseTenantMigrationBeforeLeavingBlockingState");
    assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
    blockingFp.wait();
    donorRst.awaitLastOpCommitted();
    const donorDoc = donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).findOne({
        tenantId: tenantId
    });
    const command = testCase.requiresReadTimestamp
        ? testCase.command(collName, donorDoc.blockTimestamp)
        : testCase.command(collName);
    const shouldBlock = !testCase.isLinearizableRead;
    if (shouldBlock) {
        command.maxTimeMS = kMaxTimeMS;
    }
    const nodes = testCase.isSupportedOnSecondaries ? donorRst.nodes : [donorPrimary];
    nodes.forEach(node => {
        const db = node.getDB(dbName);
        runCommand(
            db, command, shouldBlock ? ErrorCodes.MaxTimeMSExpired : null, testCase.isTransaction);
        checkTenantMigrationAccessBlocker(node, tenantId, {numBlockedReads: shouldBlock ? 1 : 0});
    });
    blockingFp.off();
    TenantMigrationTest.assertCommitted(
        tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationIdString));
    tenantMigrationTest.waitForMigrationGarbageCollection(migrationIdString);
}
function testBlockReadsAfterMigrationEnteredBlocking ( testCase , dbName , collName ) { const tenantId = dbName . split ( '_' ) [ 0 ] ; const migrationIdString = extractUUIDFromObject ( UUID ( ) ) ; const migrationOpts = { migrationIdString , tenantId , } ; const donorRst = tenantMigrationTest . getDonorRst ( ) ; const donorPrimary = donorRst . getPrimary ( ) ; let blockingFp = configureFailPoint ( donorPrimary , "pauseTenantMigrationBeforeLeavingBlockingState" ) ; assert . commandWorked ( tenantMigrationTest . startMigration ( migrationOpts ) ) ; blockingFp . wait ( ) ; donorRst . awaitLastOpCommitted ( ) ; const donorDoc = donorPrimary . getCollection ( TenantMigrationTest . kConfigDonorsNS ) . findOne ( { tenantId : tenantId } ) ; const command = testCase . requiresReadTimestamp ? testCase . command ( collName , donorDoc . blockTimestamp ) : testCase . command ( collName ) ; const shouldBlock = ! testCase . isLinearizableRead ; if ( shouldBlock ) { command . maxTimeMS = kMaxTimeMS ; } const nodes = testCase . isSupportedOnSecondaries ? donorRst . nodes : [ donorPrimary ] ; nodes . forEach ( node => { const db = node . getDB ( dbName ) ; runCommand ( db , command , shouldBlock ? ErrorCodes . MaxTimeMSExpired : null , testCase . isTransaction ) ; checkTenantMigrationAccessBlocker ( node , tenantId , { numBlockedReads : shouldBlock ? 1 : 0 } ) ; } ) ; blockingFp . off ( ) ; TenantMigrationTest . assertCommitted ( tenantMigrationTest . waitForMigrationToComplete ( migrationOpts ) ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationIdString ) ) ; tenantMigrationTest . waitForMigrationGarbageCollection ( migrationIdString ) ; }
Tests that in the blocking state, the donor blocks reads with atClusterTime/afterClusterTime >
 blockTimestamp but does not block linearizable reads.
Tests that in the blocking state the donor blocks reads with atClusterTime / afterClusterTime > blockTimestamp but does not block linearizable reads .
// Wait for the migration to enter the blocking state. // Wait for the last oplog entry on the primary to be visible in the committed snapshot view of // the oplog on all secondaries to ensure that snapshot reads on the secondaries with // unspecified atClusterTime have read timestamp >= blockTimestamp.