diff options
author | Luis Osta <luis.osta@mongodb.com> | 2020-08-04 20:41:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-04 20:54:07 +0000 |
commit | d1203723ec3de880aaee081d49396b755016fcf0 (patch) | |
tree | ae5b743455260d91bad0211c527ba6c71ea38a01 | |
parent | 2ec3583b6d1a41e560f9e533b731f5f822325919 (diff) | |
download | mongo-d1203723ec3de880aaee081d49396b755016fcf0.tar.gz |
SERVER-50034 Make donorStartMigration command retries join the active migration
-rw-r--r-- | jstests/core/views/views_all_commands.js | 1 | ||||
-rw-r--r-- | jstests/replsets/tenant_migration_donor_state_machine.js | 38 | ||||
-rw-r--r-- | src/mongo/db/repl/tenant_migration_donor_util.cpp | 4 |
3 files changed, 28 insertions, 15 deletions
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js index 1f87251c9fb..57344485f8c 100644 --- a/jstests/core/views/views_all_commands.js +++ b/jstests/core/views/views_all_commands.js @@ -418,6 +418,7 @@ let viewsCommandTests = { refineCollectionShardKey: {skip: isUnrelated}, refreshLogicalSessionCacheNow: {skip: isAnInternalCommand}, reapLogicalSessionCacheNow: {skip: isAnInternalCommand}, + recipientSyncData: {skip: isUnrelated}, refreshSessions: {skip: isUnrelated}, reIndex: { command: {reIndex: "view"}, diff --git a/jstests/replsets/tenant_migration_donor_state_machine.js b/jstests/replsets/tenant_migration_donor_state_machine.js index c4d73d7506f..cc90fd94bad 100644 --- a/jstests/replsets/tenant_migration_donor_state_machine.js +++ b/jstests/replsets/tenant_migration_donor_state_machine.js @@ -23,19 +23,31 @@ const donorRst = new ReplSetTest( {nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}], name: 'donor'}); const recipientRst = new ReplSetTest({nodes: 1, name: 'recipient'}); -donorRst.startSet(); -donorRst.initiate(); -recipientRst.startSet(); -recipientRst.initiate(); - -const donorPrimary = donorRst.getPrimary(); -const recipientPrimary = recipientRst.getPrimary(); -const kRecipientConnString = recipientRst.getURL(); const kDBPrefix = 'testDb'; const kConfigDonorsNS = "config.tenantMigrationDonors"; +let donorPrimary; +let recipientPrimary; +let kRecipientConnString; + +const setup = () => { + donorRst.startSet(); + donorRst.initiate(); + recipientRst.startSet(); + recipientRst.initiate(); + + donorPrimary = donorRst.getPrimary(); + recipientPrimary = recipientRst.getPrimary(); + kRecipientConnString = recipientRst.getURL(); +}; +const tearDown = () => { + donorRst.stopSet(); + recipientRst.stopSet(); +}; + (() => { // Test the case where the migration commits. + setup(); const dbName = kDBPrefix + "Commit"; function startMigration(host, recipientConnString, dbName) { @@ -88,11 +100,13 @@ const kConfigDonorsNS = "config.tenantMigrationDonors"; const recipientSyncDataMetrics = recipientPrimary.adminCommand({serverStatus: 1}).metrics.commands.recipientSyncData; assert.eq(recipientSyncDataMetrics.failed, 0); - assert.neq(recipientSyncDataMetrics.total, 0); + assert.eq(recipientSyncDataMetrics.total, 2); + tearDown(); })(); (() => { // Test the case where the migration aborts. + setup(); const dbName = kDBPrefix + "Abort"; let abortFp = configureFailPoint(donorPrimary, "abortTenantMigrationAfterBlockingStarts"); @@ -123,9 +137,7 @@ const kConfigDonorsNS = "config.tenantMigrationDonors"; const recipientSyncDataMetrics = recipientPrimary.adminCommand({serverStatus: 1}).metrics.commands.recipientSyncData; assert.eq(recipientSyncDataMetrics.failed, 0); - assert.neq(recipientSyncDataMetrics.total, 0); + assert.eq(recipientSyncDataMetrics.total, 2); + tearDown(); })(); - -donorRst.stopSet(); -recipientRst.stopSet(); })(); diff --git a/src/mongo/db/repl/tenant_migration_donor_util.cpp b/src/mongo/db/repl/tenant_migration_donor_util.cpp index c33ab2714f8..ca0e8e99553 100644 --- a/src/mongo/db/repl/tenant_migration_donor_util.cpp +++ b/src/mongo/db/repl/tenant_migration_donor_util.cpp @@ -265,7 +265,7 @@ void sendRecipientSyncDataCommand(OperationContext* opCtx, donorConnectionString, donorStateDoc.getDatabasePrefix().toString(), ReadPreferenceSetting()); - + request.setReturnAfterReachingOpTime(donorStateDoc.getBlockTimestamp()); return request.toBSON(BSONObj()); }()); @@ -317,7 +317,7 @@ void startMigration(OperationContext* opCtx, TenantMigrationDonorDocument donorS updateDonorStateDocument(opCtx, donorStateDoc, TenantMigrationDonorStateEnum::kBlocking); - // TODO: Send recipientSyncData with returnAfterReachingTimestamp set to the blockTimestamp. + sendRecipientSyncDataCommand(opCtx, donorStateDoc); pauseTenantMigrationAfterBlockingStarts.pauseWhileSet(opCtx); |