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

1.x-stable reconnect doesn't work for replica sets

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 1.12.4
    • Affects Version/s: 1.12.3
    • Component/s: Replica Set
    • Labels:
      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.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            grddev Gustav Munkby
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: