diff options
author | jannaerin <golden.janna@gmail.com> | 2020-05-19 13:59:35 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-19 21:21:44 +0000 |
commit | 820cc0f7b703ea0949c7a3c508d6708eed3d3afb (patch) | |
tree | c5aa45abc7fe7bf88f44910f0d52c3ec404d7659 | |
parent | bd04cc801768df02a4b8688753e42e0e6f90cfa8 (diff) | |
download | mongo-820cc0f7b703ea0949c7a3c508d6708eed3d3afb.tar.gz |
SERVER-48298 Force refresh on removeShard and addShard
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp index 0b0a8f0923b..db76b3c46c0 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp @@ -726,6 +726,10 @@ StatusWith<std::string> ShardingCatalogManager::addShard( // Ensure the added shard is visible to this process. auto shardRegistry = Grid::get(opCtx)->shardRegistry(); + if (!shardRegistry->reload(opCtx)) { + shardRegistry->reload(opCtx); + } + if (!shardRegistry->getShard(opCtx, shardType.getName()).isOK()) { return {ErrorCodes::OperationFailed, "Could not find shard metadata for shard after adding it. This most likely " @@ -854,8 +858,13 @@ RemoveShardProgress ShardingCatalogManager::removeShard(OperationContext* opCtx, str::stream() << "error completing removeShard operation on: " << name); // The shard which was just removed must be reflected in the shard registry, before the replica - // set monitor is removed, otherwise the shard would be referencing a dropped RSM - Grid::get(opCtx)->shardRegistry()->reload(opCtx); + // set monitor is removed, otherwise the shard would be referencing a dropped RSM. Check that + // this reload did not join an already running reload to be sure it picks up that the shard was + // removed. + if (!Grid::get(opCtx)->shardRegistry()->reload(opCtx)) { + Grid::get(opCtx)->shardRegistry()->reload(opCtx); + } + ReplicaSetMonitor::remove(name); // Record finish in changelog |