-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Replica Set
-
None
Given a replica set, if you try connecting to a single server, the topology will be set to Single and the only server that will end up in the client.cluster.servers array will be the arbiter (or maybe a random one.)
That means auth likely fails.
The logs do show that servers were added to the cluster, however they're not "really added" as you can see below.
irb(main):003:0> c = Mongo::Client.new(["member1.redacted:10006"], {user: 'admin', password: <redacted>}) DEBUG -- : MONGODB | Adding member1.redacted:10006 to the cluster. | runtime: 0.0041ms DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 377.3241ms DEBUG -- : MONGODB | Adding member2.redacted:10006 to the cluster. | runtime: 0.0010ms DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 375.6218ms DEBUG -- : MONGODB | Adding arbiter.redacted:10006 to the cluster. | runtime: 0.0012ms DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 443.0041ms => #<Mongo::Client:0x2235523940 cluster=member1.redacted:10006, member2.redacted:10006, arbiter.redacted:10006> irb(main):004:0> c.cluster.servers => [#<Mongo::Server:0x2240506960 address=arbiter.redacted:10006>]
This in turn also makes it difficult to stop the monitor threads running off of the other servers which are lost somewhere. Explaining why we're leaking threads and some memory.
Could this be a multi-threading issue? The code seems right to me... but it happens to only keep one server. https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/cluster.rb#L67-L77