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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Trivial - P5
    • Resolution: Fixed
    • 1.12.3
    • 1.12.4
    • Replica Set
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: