From da663d32d6f62d0ca48e1944fda8b3abe362b0cd Mon Sep 17 00:00:00 2001 From: Vesselina Ratcheva Date: Mon, 5 Apr 2021 17:19:00 +0000 Subject: SERVER-53563 Cancel tenant migrations on FCV change (donor side) --- .../tenant_migration_donor_abort_on_fcv_change.js | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js (limited to 'jstests') diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js new file mode 100644 index 00000000000..0e958568cc9 --- /dev/null +++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js @@ -0,0 +1,70 @@ +/** + * Tests that the donor cancels all migrations when its FCV changes. + * @tags: [requires_majority_read_concern, incompatible_with_windows_tls] + */ + +(function() { +"use strict"; + +load("jstests/libs/fail_point_util.js"); +load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject' +load("jstests/libs/parallelTester.js"); // for 'Thread' +load("jstests/replsets/rslib.js"); // for 'setLogVerbosity' +load("jstests/replsets/libs/tenant_migration_test.js"); +load("jstests/replsets/libs/tenant_migration_util.js"); + +const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()}); +if (!tenantMigrationTest.isFeatureFlagEnabled()) { + jsTestLog("Skipping test because the tenant migrations feature flag is disabled"); + return; +} + +const tenantId = "testTenantId"; +const dbName = tenantMigrationTest.tenantDB(tenantId, "testDB"); +const collName = "testColl"; + +const donorRst = tenantMigrationTest.getDonorRst(); +const donorPrimary = tenantMigrationTest.getDonorPrimary(); +const donorDB = donorPrimary.getDB(dbName); + +setLogVerbosity([donorPrimary], {"tenantMigration": {"verbosity": 3}}); + +tenantMigrationTest.insertDonorDB(dbName, collName); + +const migrationId = UUID(); +const migrationIdString = extractUUIDFromObject(migrationId); +const migrationOpts = { + migrationIdString: migrationIdString, + recipientConnString: tenantMigrationTest.getRecipientConnString(), + tenantId: tenantId, +}; + +const hangWhileMigratingFP = + configureFailPoint(donorDB, "pauseTenantMigrationBeforeLeavingAbortingIndexBuildsState"); + +// Start a migration and wait for donor to hang at the failpoint. +assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts)); + +hangWhileMigratingFP.wait(); + +// Initiate a downgrade and let it complete. +assert.commandWorked( + donorPrimary.adminCommand({setFeatureCompatibilityVersion: lastContinuousFCV})); + +// Upgrade again and finish the test. +assert.commandWorked(donorPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV})); + +hangWhileMigratingFP.off(); + +const stateRes = + assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts)); +assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted); +assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted); + +tenantMigrationTest.waitForDonorNodesToReachState( + donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kAborted); + +assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString)); + +tenantMigrationTest.stop(); +})(); \ No newline at end of file -- cgit v1.2.1