summaryrefslogtreecommitdiff
path: root/src/mongo/s/client
diff options
context:
space:
mode:
authorJaume Moragues <jaume.moragues@mongodb.com>2020-11-12 09:38:50 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-12 10:00:22 +0000
commit916c466afac10d34e61b6ca42a12e35d7c4828f1 (patch)
treebc6ca4106f5a028862af94e56344b66b8f6568e5 /src/mongo/s/client
parentdc1a4041787f99326b525c7109b97a834535d6f5 (diff)
downloadmongo-916c466afac10d34e61b6ca42a12e35d7c4828f1.tar.gz
SERVER-52629 Apply lookup by ShardId first in non config shards
Diffstat (limited to 'src/mongo/s/client')
-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)) {