-
Type: Bug
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: 1.12.3
-
Component/s: Replica Set
-
None
The following code fails in both MRI and JRuby (but with different failures)
client = Mongo::MongoClient.from_uri('mongodb://rs-host-1,rs-host-2,rs-host-3')
client.reconnect
The resulting stack trace looks like this (for MRI)
Mongo::ConnectionFailure: Failed to connect to a master node at : from mongo_client.rb:417:in `connect'
The problem seems to be that reconnect is aliased to MongoClient#connect also for MongoReplicaSetClient. Given that @host and @port are undefined for a MongoReplicaSetClient that operation doesn't make much sense. I'm guessing that reconnect should either not be exposed at all for replica sets, or be aliased to connect in its own class.
In the end, for our use case, we should have been using refresh, rather than reconnect, but still, the reconnect behavior is rather surprising.