diff options
author | Misha Tyulenev <misha@mongodb.com> | 2018-04-17 13:29:24 -0400 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2018-04-17 13:55:21 -0400 |
commit | 730a60e529046946f737955feba98ee4412a0c4d (patch) | |
tree | 6a85411f40d5decc27dc2a2a975b8e082ea1a28f | |
parent | 222864b678f06c0170026a2899eac62bf563dccb (diff) | |
download | mongo-730a60e529046946f737955feba98ee4412a0c4d.tar.gz |
SERVER-34363: move reload shard registry in addShard command from ON_BLOCK_EXIT
-rw-r--r-- | src/mongo/s/commands/cluster_add_shard_cmd.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/s/commands/cluster_add_shard_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_cmd.cpp index 8a3abf08b81..a762a291860 100644 --- a/src/mongo/s/commands/cluster_add_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_add_shard_cmd.cpp @@ -77,22 +77,21 @@ public: BSONObjBuilder& result) override { auto parsedRequest = uassertStatusOK(AddShardRequest::parseFromMongosCommand(cmdObj)); - // Force a reload of this node's shard list cache at the end of this command. - ON_BLOCK_EXIT([opCtx] { - if (!Grid::get(opCtx)->shardRegistry()->reload(opCtx)) { - Grid::get(opCtx)->shardRegistry()->reload(opCtx); - } - }); - auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); - auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts( + + // Force a reload of this node's shard list cache at the end of this command. + auto cmdResponseWithStatus = configShard->runCommandWithFixedRetryAttempts( opCtx, kPrimaryOnlyReadPreference, "admin", CommandHelpers::appendMajorityWriteConcern(CommandHelpers::appendPassthroughFields( cmdObj, parsedRequest.toCommandForConfig())), - Shard::RetryPolicy::kIdempotent)); + Shard::RetryPolicy::kIdempotent); + if (!Grid::get(opCtx)->shardRegistry()->reload(opCtx)) { + Grid::get(opCtx)->shardRegistry()->reload(opCtx); + } + auto cmdResponse = uassertStatusOK(cmdResponseWithStatus); CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.response, &result); return true; } |