jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
/**
 * Tests that the donor blocks writes that are executed in the blocking state and rejects them after
 * the migration commits.
 */
Tests that the donor blocks writes that are executed in the blocking state and rejects them after
the migration commits.
Tests that the donor blocks writes that are executed in the blocking state and rejects them after the migration commits .
function testRejectBlockedWritesAfterMigrationCommitted(testCase, testOpts) {
    const tenantId = testOpts.dbName.split('_')[0];
    const migrationOpts = {
        migrationIdString: extractUUIDFromObject(UUID()),
        tenantId,
    };
    let blockingFp =
        configureFailPoint(testOpts.primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
    let resumeMigrationThread =
        new Thread(resumeMigrationAfterBlockingWrite, testOpts.primaryHost, tenantId, 1);
    resumeMigrationThread.start();
    assert.commandWorked(
        tenantMigrationTest.startMigration(migrationOpts, {enableDonorStartMigrationFsync: true}));
    blockingFp.wait();
    runCommand(testOpts, ErrorCodes.TenantMigrationCommitted);
    resumeMigrationThread.join();
    TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(
        migrationOpts, false ));
    testCase.assertCommandFailed(testOpts.primaryDB, testOpts.dbName, testOpts.collName);
    checkTenantMigrationAccessBlocker(
        testOpts.primaryDB, tenantId, {numBlockedWrites: 1, numTenantMigrationCommittedErrors: 1});
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
    tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
}
function testRejectBlockedWritesAfterMigrationCommitted ( testCase , testOpts ) { const tenantId = testOpts . dbName . split ( '_' ) [ 0 ] ; const migrationOpts = { migrationIdString : extractUUIDFromObject ( UUID ( ) ) , tenantId , } ; let blockingFp = configureFailPoint ( testOpts . primaryDB , "pauseTenantMigrationBeforeLeavingBlockingState" ) ; let resumeMigrationThread = new Thread ( resumeMigrationAfterBlockingWrite , testOpts . primaryHost , tenantId , 1 ) ; resumeMigrationThread . start ( ) ; assert . commandWorked ( tenantMigrationTest . startMigration ( migrationOpts , { enableDonorStartMigrationFsync : true } ) ) ; blockingFp . wait ( ) ; runCommand ( testOpts , ErrorCodes . TenantMigrationCommitted ) ; resumeMigrationThread . join ( ) ; TenantMigrationTest . assertCommitted ( tenantMigrationTest . waitForMigrationToComplete ( migrationOpts , false ) ) ; testCase . assertCommandFailed ( testOpts . primaryDB , testOpts . dbName , testOpts . collName ) ; checkTenantMigrationAccessBlocker ( testOpts . primaryDB , tenantId , { numBlockedWrites : 1 , numTenantMigrationCommittedErrors : 1 } ) ; assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationOpts . migrationIdString ) ) ; tenantMigrationTest . waitForMigrationGarbageCollection ( migrationOpts . migrationIdString ) ; }
Tests that the donor blocks writes that are executed in the blocking state and rejects them after
 the migration commits.
Tests that the donor blocks writes that are executed in the blocking state and rejects them after the migration commits .
// Run the command after the migration enters the blocking state. // The migration should unpause and commit after the write is blocked. Verify that the write is // rejected. // Verify that the migration succeeded. /* retryOnRetryableErrors */