diff options
-rw-r--r-- | src/mongo/s/client/sharding_connection_hook.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/sharding_initialization.cpp | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/s/client/sharding_connection_hook.cpp b/src/mongo/s/client/sharding_connection_hook.cpp index 24cd459db27..05bf53722a6 100644 --- a/src/mongo/s/client/sharding_connection_hook.cpp +++ b/src/mongo/s/client/sharding_connection_hook.cpp @@ -97,7 +97,10 @@ Status _shardingRequestMetadataWriter(bool shardedConn, // Add config server optime to metadata sent to shards. std::string hostString = hostStringData.toString(); auto shard = grid.shardRegistry()->getShardNoReload(hostString); - invariant(shard); + if (!shard) { + return Status(ErrorCodes::ShardNotFound, + str::stream() << "Shard not found for server: " << hostString); + } if (shard->isConfig()) { return Status::OK(); } diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp index 1cdfa7373ce..103e40d4974 100644 --- a/src/mongo/s/sharding_initialization.cpp +++ b/src/mongo/s/sharding_initialization.cpp @@ -80,7 +80,10 @@ public: // Add config server optime to metadata sent to shards. std::string targetStr = target.toString(); auto shard = grid.shardRegistry()->getShardNoReload(targetStr); - invariant(shard); + if (!shard) { + return Status(ErrorCodes::ShardNotFound, + str::stream() << "Shard not found for server: " << targetStr); + } if (shard->isConfig()) { return Status::OK(); } |