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 aborts.
 */
Tests that the donor blocks writes that are executed in the blocking state and rejects them after
the migration aborts.
Tests that the donor blocks writes that are executed in the blocking state and rejects them after the migration aborts .
function testRejectBlockedWritesAfterMigrationAborted(testCase, testOpts) {
    const tenantId = testOpts.dbName.split('_')[0];
    const migrationOpts = {
        migrationIdString: extractUUIDFromObject(UUID()),
        tenantId,
    };
    let blockingFp =
        configureFailPoint(testOpts.primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
    let abortFp =
        configureFailPoint(testOpts.primaryDB, "abortTenantMigrationBeforeLeavingBlockingState");
    let resumeMigrationThread =
        new Thread(resumeMigrationAfterBlockingWrite, testOpts.primaryHost, tenantId, 1);
    assert.commandWorked(
        tenantMigrationTest.startMigration(migrationOpts, {enableDonorStartMigrationFsync: true}));
    resumeMigrationThread.start();
    blockingFp.wait();
    runCommand(testOpts, ErrorCodes.TenantMigrationAborted);
    resumeMigrationThread.join();
    TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(
        migrationOpts, false ));
    abortFp.off();
    testCase.assertCommandFailed(testOpts.primaryDB, testOpts.dbName, testOpts.collName);
    checkTenantMigrationAccessBlocker(
        testOpts.primaryDB, tenantId, {numBlockedWrites: 1, numTenantMigrationAbortedErrors: 1});
    assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
    tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
}
function testRejectBlockedWritesAfterMigrationAborted ( testCase , testOpts ) { const tenantId = testOpts . dbName . split ( '_' ) [ 0 ] ; const migrationOpts = { migrationIdString : extractUUIDFromObject ( UUID ( ) ) , tenantId , } ; let blockingFp = configureFailPoint ( testOpts . primaryDB , "pauseTenantMigrationBeforeLeavingBlockingState" ) ; let abortFp = configureFailPoint ( testOpts . primaryDB , "abortTenantMigrationBeforeLeavingBlockingState" ) ; let resumeMigrationThread = new Thread ( resumeMigrationAfterBlockingWrite , testOpts . primaryHost , tenantId , 1 ) ; assert . commandWorked ( tenantMigrationTest . startMigration ( migrationOpts , { enableDonorStartMigrationFsync : true } ) ) ; resumeMigrationThread . start ( ) ; blockingFp . wait ( ) ; runCommand ( testOpts , ErrorCodes . TenantMigrationAborted ) ; resumeMigrationThread . join ( ) ; TenantMigrationTest . assertAborted ( tenantMigrationTest . waitForMigrationToComplete ( migrationOpts , false ) ) ; abortFp . off ( ) ; testCase . assertCommandFailed ( testOpts . primaryDB , testOpts . dbName , testOpts . collName ) ; checkTenantMigrationAccessBlocker ( testOpts . primaryDB , tenantId , { numBlockedWrites : 1 , numTenantMigrationAbortedErrors : 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 aborts.
Tests that the donor blocks writes that are executed in the blocking state and rejects them after the migration aborts .
// Run the command after the migration enters the blocking state. // The migration should unpause and abort after the write is blocked. Verify that the write is // rejected. // Verify that the migration aborted due to the simulated error. /* retryOnRetryableErrors */