diff options
author | Luis Osta <luis.osta@mongodb.com> | 2020-07-15 21:57:35 +0000 |
---|---|---|
committer | Luis Osta <luis.osta@mongodb.com> | 2020-07-17 15:26:06 +0000 |
commit | 8ebfdfe3066aff3a04e0ca739af16d94cea5d3a1 (patch) | |
tree | c8a9e1048cc1e60f5dbac1b878461cf4a3cb92fa | |
parent | a701b8503794223b2ae81b7aa7214b4775562ed1 (diff) | |
download | mongo-8ebfdfe3066aff3a04e0ca739af16d94cea5d3a1.tar.gz |
added asserts to test
-rw-r--r-- | jstests/replsets/migrating_tenant_mtab_blocks_writes.js | 8 | ||||
-rw-r--r-- | src/mongo/db/repl/migrating_tenant_donor_util.cpp | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/jstests/replsets/migrating_tenant_mtab_blocks_writes.js b/jstests/replsets/migrating_tenant_mtab_blocks_writes.js index 5206426b98f..ca8dcdcc2d9 100644 --- a/jstests/replsets/migrating_tenant_mtab_blocks_writes.js +++ b/jstests/replsets/migrating_tenant_mtab_blocks_writes.js @@ -16,6 +16,8 @@ }); }; + // the value of the access enum in MigratingTenantAccessBlocker for the 'kBlockWritesAndReads' access state. + const kBlockReadsAndWrites = 2; const rst = new ReplSetTest({ nodes: 1 }); rst.startSet(); rst.initiate(); @@ -34,8 +36,10 @@ assert.commandWorked(runDonorStartMigrationCommand(donorPrimary, kMigrationId, kRecipientConnectionString, kDBPrefixes, kReadPreference)); jsTest.log('Running the serverStatus command.') - const res = donorPrimary.adminCommand({ serverStatus: 1 }); - jsTest.log(tojson(res)); + const migratingTenantServerStatus = donorPrimary.adminCommand({ serverStatus: 1 }).migratingTenantAccessBlocker; + + assert.eq(migratingTenantServerStatus.access, kBlockReadsAndWrites); + assert(migratingTenantServerStatus.blockTimestamp); rst.stopSet(); })();
\ No newline at end of file diff --git a/src/mongo/db/repl/migrating_tenant_donor_util.cpp b/src/mongo/db/repl/migrating_tenant_donor_util.cpp index 84c93afacfd..7b35de0404e 100644 --- a/src/mongo/db/repl/migrating_tenant_donor_util.cpp +++ b/src/mongo/db/repl/migrating_tenant_donor_util.cpp @@ -90,8 +90,8 @@ void onTransitionToBlocking(OperationContext* opCtx, TenantMigrationDonorDocumen } /** - * Creates a MigratingTenantAccess blocker and then adds it to the MtabByPrefix container through - * the donor document's databasePrefix. + * Creates a MigratingTenantAccess blocker, and makes it start blocking writes. Then adds it to + * the MigratingTenantAccessBlockerByPrefix container using the donor document's databasePrefix as the key. */ void startTenantMigrationBlockOnPrimary(OperationContext* opCtx, const TenantMigrationDonorDocument& donorDoc) { @@ -144,15 +144,11 @@ void dataSync(OperationContext* opCtx, const TenantMigrationDonorDocument& origi auto oplogSlot = repl::LocalOplogInfo::get(opCtx)->getNextOpTimes(opCtx, 1U)[0]; - TenantMigrationDonorDocument updatedDoc; - updatedDoc.setId(originalDoc.getId()); - updatedDoc.setDatabasePrefix(originalDoc.getDatabasePrefix()); + TenantMigrationDonorDocument updatedDoc = originalDoc; updatedDoc.setState(TenantMigrationDonorStateEnum::kBlocking); updatedDoc.setBlockTimestamp(oplogSlot.getTimestamp()); - CollectionUpdateArgs args; - // ! Since the updatedDoc isn't properly created, this will throw an error args.update = updatedDoc.toBSON(); args.criteria = BSON("_id" << originalDoc.getId()); args.oplogSlot = oplogSlot; @@ -205,6 +201,9 @@ void onTenantMigrationDonorStateTransition(OperationContext* opCtx, const BSONOb } } +/** + * TODO - ADD DESCRIPTION EXPLAINING PURPOSE + */ void persistDonorStateMachine(OperationContext* opCtx, const TenantMigrationDonorDocument& donorDoc) { PersistentTaskStore<TenantMigrationDonorDocument> store( |