diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2019-12-19 20:59:34 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-19 20:59:34 +0000 |
commit | 6b111d1538bb75b070917630649c4d3c80152916 (patch) | |
tree | 754cd2465f7f008abc61ac4a0c1cded7c5ae4bb8 /src | |
parent | 54ed086026aba498ae9d51a0fd5094cc5acf1852 (diff) | |
download | mongo-6b111d1538bb75b070917630649c4d3c80152916.tar.gz |
SERVER-45244 Add forgetMigration method to MigrationCoordinator
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/migration_coordinator.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/s/migration_coordinator.h | 5 | ||||
-rw-r--r-- | src/mongo/db/s/migration_util.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/s/migration_util.h | 6 |
4 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/db/s/migration_coordinator.cpp b/src/mongo/db/s/migration_coordinator.cpp index f1deb950a17..787b107b0c3 100644 --- a/src/mongo/db/s/migration_coordinator.cpp +++ b/src/mongo/db/s/migration_coordinator.cpp @@ -98,6 +98,11 @@ void MigrationCoordinator::abortMigrationOnDonorAndRecipient(OperationContext* o opCtx, _migrationInfo.getRecipientShardId(), _migrationInfo.getId()); } +void MigrationCoordinator::forgetMigration(OperationContext* opCtx) { + LOG(0) << "Deleting migration coordinator document for migration " << _migrationInfo.getId(); + migrationutil::deleteMigrationCoordinatorDocumentLocally(opCtx, _migrationInfo.getId()); +} + } // namespace migrationutil } // namespace mongo diff --git a/src/mongo/db/s/migration_coordinator.h b/src/mongo/db/s/migration_coordinator.h index c0c2327a2c2..245967f57f7 100644 --- a/src/mongo/db/s/migration_coordinator.h +++ b/src/mongo/db/s/migration_coordinator.h @@ -80,6 +80,11 @@ public: */ void abortMigrationOnDonorAndRecipient(OperationContext* opCtx); + /** + * Deletes the persistent state for this migration from config.migrationCoordinators. + */ + void forgetMigration(OperationContext* opCtx); + private: MigrationCoordinatorDocument _migrationInfo; }; diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp index 9a02d422ee1..2d8ca8a2aaa 100644 --- a/src/mongo/db/s/migration_util.cpp +++ b/src/mongo/db/s/migration_util.cpp @@ -369,5 +369,13 @@ void markAsReadyRangeDeletionTaskLocally(OperationContext* opCtx, const UUID& mi store.update(opCtx, query, update); } + +void deleteMigrationCoordinatorDocumentLocally(OperationContext* opCtx, const UUID& migrationId) { + PersistentTaskStore<MigrationCoordinatorDocument> store( + opCtx, NamespaceString::kMigrationCoordinatorsNamespace); + store.remove(opCtx, + QUERY(MigrationCoordinatorDocument::kIdFieldName << migrationId), + {1, WriteConcernOptions::SyncMode::UNSET, Seconds(0)}); +} } // namespace migrationutil } // namespace mongo diff --git a/src/mongo/db/s/migration_util.h b/src/mongo/db/s/migration_util.h index 7c026bd8e1b..bd54b2acd21 100644 --- a/src/mongo/db/s/migration_util.h +++ b/src/mongo/db/s/migration_util.h @@ -152,5 +152,11 @@ void markAsReadyRangeDeletionTaskLocally(OperationContext* opCtx, const UUID& mi void markAsReadyRangeDeletionTaskOnRecipient(OperationContext* opCtx, const ShardId& recipientId, const UUID& migrationId); + +/** + * Deletes the migration coordinator document with the specified id from + * config.migrationCoordinators without waiting for majority writeConcern. + */ +void deleteMigrationCoordinatorDocumentLocally(OperationContext* opCtx, const UUID& migrationId); } // namespace migrationutil } // namespace mongo |