summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Chan <jason.chan@mongodb.com>2021-07-12 21:28:34 +0000
committerJason Chan <jason.chan@mongodb.com>2021-07-13 23:24:10 +0000
commit92662765968eff784a82adea2f57ee5d1125712d (patch)
treeffbca8f157682723dbfd429bce1f91b4349acb08 /src
parent1184f004a99660de6f5e745573419bda8a28c0e9 (diff)
downloadmongo-92662765968eff784a82adea2f57ee5d1125712d.tar.gz
SERVER-58398 TenantMigrationDonor will not retry recipientSyncData on non-retriable interruption errors
(cherry picked from commit bbd0b90085c06de2882e48d68812ac822a4412f9)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/tenant_migration_donor_service.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mongo/db/repl/tenant_migration_donor_service.cpp b/src/mongo/db/repl/tenant_migration_donor_service.cpp
index 0ac4d9c671e..6340b6a761b 100644
--- a/src/mongo/db/repl/tenant_migration_donor_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_donor_service.cpp
@@ -88,7 +88,7 @@ bool shouldStopInsertingDonorStateDoc(Status status) {
return status.isOK() || status == ErrorCodes::ConflictingOperationInProgress;
}
-bool shouldStopSendingRecipientCommand(Status status) {
+bool shouldStopSendingRecipientForgetMigrationCommand(Status status) {
return status.isOK() ||
!(ErrorCodes::isRetriableError(status) ||
// Returned if findHost() is unable to target the recipient in 15 seconds, which may
@@ -97,6 +97,14 @@ bool shouldStopSendingRecipientCommand(Status status) {
ErrorCodes::isInterruption(status));
}
+bool shouldStopSendingRecipientSyncDataCommand(Status status) {
+ return status.isOK() ||
+ !(ErrorCodes::isRetriableError(status) ||
+ // Returned if findHost() is unable to target the recipient in 15 seconds, which may
+ // happen after a failover.
+ status == ErrorCodes::FailedToSatisfyReadPreference);
+}
+
bool shouldStopFetchingRecipientClusterTimeKeyDocs(Status status) {
return status.isOK() ||
!(ErrorCodes::isRetriableError(status) || ErrorCodes::isInterruption(status));
@@ -645,6 +653,7 @@ ExecutorFuture<void> TenantMigrationDonorService::Instance::_sendCommandToRecipi
std::shared_ptr<RemoteCommandTargeter> recipientTargeterRS,
const BSONObj& cmdObj,
const CancellationToken& token) {
+ const bool isRecipientSyncDataCmd = cmdObj.hasField(RecipientSyncData::kCommandName);
return AsyncTry(
[this, self = shared_from_this(), executor, recipientTargeterRS, cmdObj, token] {
return recipientTargeterRS->findHost(kPrimaryOnlyReadPreference, token)
@@ -673,7 +682,16 @@ ExecutorFuture<void> TenantMigrationDonorService::Instance::_sendCommandToRecipi
});
});
})
- .until([token](Status status) { return shouldStopSendingRecipientCommand(status); })
+ .until([token, cmdObj, isRecipientSyncDataCmd](Status status) {
+ if (isRecipientSyncDataCmd) {
+ return shouldStopSendingRecipientSyncDataCommand(status);
+ } else {
+ // If the recipient command is not 'recipientSyncData', it must be
+ // 'recipientForgetMigration'.
+ invariant(cmdObj.hasField(RecipientForgetMigration::kCommandName));
+ return shouldStopSendingRecipientForgetMigrationCommand(status);
+ }
+ })
.withBackoffBetweenIterations(kExponentialBackoff)
.on(**executor, token);
}