summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/config/configsvr_move_primary_command.cpp
diff options
context:
space:
mode:
authorJason Zhang <jason.zhang@mongodb.com>2019-07-08 17:59:13 -0400
committerJason Zhang <jason.zhang@mongodb.com>2019-07-10 15:35:08 -0400
commit0434f018920206c197ab06b96e1a74dcbdf8885a (patch)
tree2c0d9dfc909ae4a68085792b719ff8a0fdc9f454 /src/mongo/db/s/config/configsvr_move_primary_command.cpp
parent3f3c46d39e40d38102250bd09cc6f41cb141914b (diff)
downloadmongo-0434f018920206c197ab06b96e1a74dcbdf8885a.tar.gz
SERVER-35807 Prepend _movePrimary and _cloneCatalogData internal commands with "_shardsvr".
Diffstat (limited to 'src/mongo/db/s/config/configsvr_move_primary_command.cpp')
-rw-r--r--src/mongo/db/s/config/configsvr_move_primary_command.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/db/s/config/configsvr_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_move_primary_command.cpp
index f0272e1a92c..eea3b876e46 100644
--- a/src/mongo/db/s/config/configsvr_move_primary_command.cpp
+++ b/src/mongo/db/s/config/configsvr_move_primary_command.cpp
@@ -181,7 +181,7 @@ public:
}
ShardMovePrimary shardMovePrimaryRequest;
- shardMovePrimaryRequest.set_movePrimary(NamespaceString(dbname));
+ shardMovePrimaryRequest.set_shardsvrMovePrimary(NamespaceString(dbname));
shardMovePrimaryRequest.setTo(toShard->getId().toString());
auto cmdResponse = uassertStatusOK(fromShard->runCommandWithFixedRetryAttempts(
@@ -192,6 +192,21 @@ public:
CommandHelpers::appendPassthroughFields(cmdObj, shardMovePrimaryRequest.toBSON())),
Shard::RetryPolicy::kIdempotent));
+ // If the `fromShard` is on v4.2 or earlier, it will not recognize the command name
+ // _shardsvrMovePrimary. We will retry the command with the old name _movePrimary.
+ if (cmdResponse.commandStatus == ErrorCodes::CommandNotFound) {
+ ShardMovePrimary legacyShardMovePrimaryRequest;
+ legacyShardMovePrimaryRequest.set_movePrimary(NamespaceString(dbname));
+ legacyShardMovePrimaryRequest.setTo(toShard->getId().toString());
+ cmdResponse = uassertStatusOK(fromShard->runCommandWithFixedRetryAttempts(
+ opCtx,
+ ReadPreferenceSetting(ReadPreference::PrimaryOnly),
+ "admin",
+ CommandHelpers::appendMajorityWriteConcern(CommandHelpers::appendPassthroughFields(
+ cmdObj, legacyShardMovePrimaryRequest.toBSON())),
+ Shard::RetryPolicy::kIdempotent));
+ }
+
CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.response, &result);
return true;