Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-900

Connecting to a single server of a replica set connects to an arbiter

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • 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

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            jeromegn Jerome Gravel-Niquet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: