diff options
author | Spencer T Brody <spencer@mongodb.com> | 2015-09-25 14:03:52 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2015-09-25 14:03:52 -0400 |
commit | 2f2886647d6340ca4b364599e5a455442e8d5656 (patch) | |
tree | 10678a95f9424e92c46d81e756c2b834038cbf48 /src | |
parent | 9b96ee5e6316d5f1bb1d2f49920574a934c18969 (diff) | |
download | mongo-2f2886647d6340ca4b364599e5a455442e8d5656.tar.gz |
SERVER-20625 SERVER-20644 Don't crash if trying to talking to a server that the ShardRegistry doesn't know about
Diffstat (limited to 'src')
-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(); } |