jstests/replsets/tenant_migration_concurrent_migrations_stress_test.js
// the wait should be short) and creates another migration.
the wait should be short) and creates another migration.
the wait should be short ) and creates another migration .
function retryAbortedMigration(id) {
    let tenantId = migrationOptsArray[id].tenantId;
    jsTestLog(
        `Forgetting and restarting aborted migration
        ${migrationOptsArray[id].migrationIdString} for tenant: ${tenantId}`);
    let waitState = tenantMigrationTest.waitForMigrationToComplete(migrationOptsArray[id]);
    assert.commandWorked(waitState);
    if (waitState.state != TenantMigrationTest.DonorState.kAborted) {
        jsTestLog(`Migration was supposed to be aborted, got: ${tojson(waitState)}`);
        return;
    }
    assert.commandWorked(
        tenantMigrationTest.forgetMigration(migrationOptsArray[id].migrationIdString));
    const dbName = tenantMigrationTest.tenantDB(tenantId, "testDB");
    let db = recipientPrimary.getDB(dbName);
    try {
        db.dropDatabase();
    } catch (err) {
        jsTestLog(`Dropping recipient DB: ${tojson(err)}`);
    }
    migrationOptsArray[id].migrationIdString = extractUUIDFromObject(UUID());
    assert.soon(function() {
        let status = tenantMigrationTest.startMigration(migrationOptsArray[id]);
        if (!status.ok) {
            jsTestLog(`${tojson(status)}`);
        }
        return status.ok;
    }, 'Failed to start', 60 * 1000, 5 * 1000);
}
function retryAbortedMigration ( id ) { let tenantId = migrationOptsArray [ id ] . tenantId ; jsTestLog ( ` ${ migrationOptsArray [ id ] . migrationIdString } ${ tenantId } ` ) ; let waitState = tenantMigrationTest . waitForMigrationToComplete ( migrationOptsArray [ id ] ) ; assert . commandWorked ( waitState ) ; if ( waitState . state != TenantMigrationTest . DonorState . kAborted ) { jsTestLog ( ` ${ tojson ( waitState ) } ` ) ; return ; } assert . commandWorked ( tenantMigrationTest . forgetMigration ( migrationOptsArray [ id ] . migrationIdString ) ) ; const dbName = tenantMigrationTest . tenantDB ( tenantId , "testDB" ) ; let db = recipientPrimary . getDB ( dbName ) ; try { db . dropDatabase ( ) ; } catch ( err ) { jsTestLog ( ` ${ tojson ( err ) } ` ) ; } migrationOptsArray [ id ] . migrationIdString = extractUUIDFromObject ( UUID ( ) ) ; assert . soon ( function ( ) { let status = tenantMigrationTest . startMigration ( migrationOptsArray [ id ] ) ; if ( ! status . ok ) { jsTestLog ( ` ${ tojson ( status ) } ` ) ; } return status . ok ; } , 'Failed to start' , 60 * 1000 , 5 * 1000 ) ; }
the wait should be short) and creates another migration.
the wait should be short ) and creates another migration .
// The `currentOp()` seems to be lagging so this condition actually happens. // We simply ignore this condition. // Note: this is not a bug, the code is fast enough to forget, replace Id // and restart the migration with the same name to get a stale currentOp() result // from previous attempt with same name. As we replace UUID() below it is guaranteed // that we do not restart the same migration and 'aborted' state is terminal. The // currentOp() is stale because forgetting the migration only marks it for garbage // collection, which happens later. // Drop recipient DB. // Replace migration UUID. // Old migration needs to be garbage collected before this works.