jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
/**
 * Tests that after the migration commits, the donor rejects linearizable reads and reads with
 * atClusterTime/afterClusterTime >= blockTimestamp.
 */
Tests that after the migration commits, the donor rejects linearizable reads and reads with
atClusterTime/afterClusterTime >= blockTimestamp.
Tests that after the migration commits the donor rejects linearizable reads and reads with atClusterTime / afterClusterTime > = blockTimestamp .
function testRejectReadsAfterMigrationCommitted(testCase, dbName, collName) {
    const tenantId = dbName.split('_')[0];
    const migrationIdString = extractUUIDFromObject(UUID());
    const migrationOpts = {
        migrationIdString,
        tenantId,
    };
    const donorRst = tenantMigrationTest.getDonorRst();
    const donorPrimary = donorRst.getPrimary();
    TenantMigrationTest.assertCommitted(
        tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
    donorRst.awaitLastOpCommitted();
    const donorDoc = donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).findOne({
        tenantId: tenantId
    });
    const nodes = testCase.isSupportedOnSecondaries ? donorRst.nodes : [donorPrimary];
    nodes.forEach(node => {
        const db = node.getDB(dbName);
        if (testCase.requiresReadTimestamp) {
            runCommand(db,
                       testCase.command(collName, donorDoc.blockTimestamp),
                       ErrorCodes.TenantMigrationCommitted,
                       testCase.isTransaction);
            runCommand(db,
                       testCase.command(collName, donorDoc.commitOrAbortOpTime.ts),
                       ErrorCodes.TenantMigrationCommitted,
                       testCase.isTransaction);
            checkTenantMigrationAccessBlocker(
                node, tenantId, {numTenantMigrationCommittedErrors: 2});
        } else {
            runCommand(db,
                       testCase.command(collName),
                       ErrorCodes.TenantMigrationCommitted,
                       testCase.isTransaction);
            checkTenantMigrationAccessBlocker(
                node, tenantId, {numTenantMigrationCommittedErrors: 1});
        }
    });
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationIdString));
    tenantMigrationTest.waitForMigrationGarbageCollection(migrationIdString);
}
function testRejectReadsAfterMigrationCommitted ( testCase , dbName , collName ) { const tenantId = dbName . split ( '_' ) [ 0 ] ; const migrationIdString = extractUUIDFromObject ( UUID ( ) ) ; const migrationOpts = { migrationIdString , tenantId , } ; const donorRst = tenantMigrationTest . getDonorRst ( ) ; const donorPrimary = donorRst . getPrimary ( ) ; TenantMigrationTest . assertCommitted ( tenantMigrationTest . runMigration ( migrationOpts , { automaticForgetMigration : false } ) ) ; donorRst . awaitLastOpCommitted ( ) ; const donorDoc = donorPrimary . getCollection ( TenantMigrationTest . kConfigDonorsNS ) . findOne ( { tenantId : tenantId } ) ; const nodes = testCase . isSupportedOnSecondaries ? donorRst . nodes : [ donorPrimary ] ; nodes . forEach ( node => { const db = node . getDB ( dbName ) ; if ( testCase . requiresReadTimestamp ) { runCommand ( db , testCase . command ( collName , donorDoc . blockTimestamp ) , ErrorCodes . TenantMigrationCommitted , testCase . isTransaction ) ; runCommand ( db , testCase . command ( collName , donorDoc . commitOrAbortOpTime . ts ) , ErrorCodes . TenantMigrationCommitted , testCase . isTransaction ) ; checkTenantMigrationAccessBlocker ( node , tenantId , { numTenantMigrationCommittedErrors : 2 } ) ; } else { runCommand ( db , testCase . command ( collName ) , ErrorCodes . TenantMigrationCommitted , testCase . isTransaction ) ; checkTenantMigrationAccessBlocker ( node , tenantId , { numTenantMigrationCommittedErrors : 1 } ) ; } } ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationIdString ) ) ; tenantMigrationTest . waitForMigrationGarbageCollection ( migrationIdString ) ; }
Tests that after the migration commits, the donor rejects linearizable reads and reads with
 atClusterTime/afterClusterTime >= blockTimestamp.
Tests that after the migration commits the donor rejects linearizable reads and reads with atClusterTime / afterClusterTime > = blockTimestamp .
// Wait for the last oplog entry on the primary to be visible in the committed snapshot view of // the oplog on all the secondaries. This is to ensure that snapshot reads on secondaries with // unspecified atClusterTime have read timestamp >= commitTimestamp.