summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2021-03-15 16:45:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-25 15:51:19 +0000
commita84c48a0d457c40a0d32da0fb61bd5e2146c1809 (patch)
tree3fe4525dab2589eb850a9019582e8fde55b803b8 /src/mongo/db/repl
parent64540ae7bb8b4298c780ecc154f866ddbc8d676c (diff)
downloadmongo-a84c48a0d457c40a0d32da0fb61bd5e2146c1809.tar.gz
SERVER-55416 Tenant migration donor shouldn't fetch keys if cancelation token has been canceled
(cherry picked from commit 373a974442db5edd9e7e7a4673eb9158e83244c7)
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/tenant_migration_donor_service.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/repl/tenant_migration_donor_service.cpp b/src/mongo/db/repl/tenant_migration_donor_service.cpp
index 67cb71fc87c..e58a4383d81 100644
--- a/src/mongo/db/repl/tenant_migration_donor_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_donor_service.cpp
@@ -65,6 +65,7 @@ MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationAfterPersistingInitialDonorStateDoc)
MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationBeforeLeavingAbortingIndexBuildsState);
MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationBeforeLeavingBlockingState);
MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationBeforeLeavingDataSyncState);
+MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationBeforeFetchingKeys);
MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationDonorBeforeWaitingForKeysToReplicate);
MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationDonorBeforeMarkingStateGarbageCollectable);
MONGO_FAIL_POINT_DEFINE(pauseTenantMigrationBeforeEnteringFutureChain);
@@ -405,6 +406,10 @@ void TenantMigrationDonorService::Instance::interrupt(Status status) {
setPromiseErrorIfNotReady(lg, _completionPromise, status);
setPromiseErrorIfNotReady(lg, _decisionPromise, status);
setPromiseErrorIfNotReady(lg, _migrationCancelablePromise, status);
+
+ if (auto fetcher = _recipientKeysFetcher.lock()) {
+ fetcher->shutdown();
+ }
}
ExecutorFuture<void>
@@ -413,7 +418,6 @@ TenantMigrationDonorService::Instance::_fetchAndStoreRecipientClusterTimeKeyDocs
std::shared_ptr<RemoteCommandTargeter> recipientTargeterRS,
const CancelationToken& serviceToken,
const CancelationToken& instanceToken) {
-
return AsyncTry([this,
self = shared_from_this(),
executor,
@@ -422,7 +426,10 @@ TenantMigrationDonorService::Instance::_fetchAndStoreRecipientClusterTimeKeyDocs
instanceToken] {
return recipientTargeterRS->findHost(kPrimaryOnlyReadPreference, instanceToken)
.thenRunOn(**executor)
- .then([this, self = shared_from_this(), executor](HostAndPort host) {
+ .then([this, self = shared_from_this(), executor, serviceToken, instanceToken](
+ HostAndPort host) {
+ pauseTenantMigrationBeforeFetchingKeys.pauseWhileSet();
+
const auto nss = NamespaceString::kKeysCollectionNamespace;
const auto cmdObj = [&] {
@@ -477,13 +484,17 @@ TenantMigrationDonorService::Instance::_fetchAndStoreRecipientClusterTimeKeyDocs
kMaxRecipientKeyDocsFindAttempts,
executor::RemoteCommandRequest::kNoTimeout),
_sslMode);
- uassertStatusOK(fetcher->schedule());
{
stdx::lock_guard<Latch> lg(_mutex);
+ checkIfReceivedDonorAbortMigration(serviceToken, instanceToken);
+ uassert(ErrorCodes::Interrupted,
+ "Donor service interrupted",
+ !serviceToken.isCanceled());
_recipientKeysFetcher = fetcher;
}
+ uassertStatusOK(fetcher->schedule());
fetcher->join();
{