summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/client/shard_registry.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp
index 28b4af8dc3c..3d5f8bc3e8d 100644
--- a/src/mongo/s/client/shard_registry.cpp
+++ b/src/mongo/s/client/shard_registry.cpp
@@ -328,7 +328,13 @@ std::shared_ptr<Shard> ShardRegistry::getConfigShard() const {
StatusWith<std::shared_ptr<Shard>> ShardRegistry::getShard(OperationContext* opCtx,
const ShardId& shardId) {
- // First check if this is a config shard lookup.
+ // First check if this is a non config shard lookup
+ // This call will may be blocking if there is an ongoing or a need of a cache rebuild
+ if (auto shard = _getData(opCtx)->findShard(shardId)) {
+ return shard;
+ }
+
+ // then check if this is a config shard (this call is blocking in any case)
{
stdx::lock_guard<Latch> lk(_mutex);
if (auto shard = _configShardData.findShard(shardId)) {
@@ -336,10 +342,6 @@ StatusWith<std::shared_ptr<Shard>> ShardRegistry::getShard(OperationContext* opC
}
}
- if (auto shard = _getData(opCtx)->findShard(shardId)) {
- return shard;
- }
-
// Reload and try again if the shard was not in the registry
reload(opCtx);
if (auto shard = _getData(opCtx)->findShard(shardId)) {