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

server monitor ismaster method fails to disconnect and fails to rescue all relevant errors

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0
    • Affects Version/s: 2.0.0
    • Component/s: None
    • None

      Mongo::Server::Monitor#ismaster does not disconnect the connection, so the scan/description-update can get stuck on bad connections and will not try to open a new connection to any restarted/recovered server. Also, there are more connection errors that can occur than are handled in the current code.

      The following is a possible fix.

        class Server
          class Monitor
            def ismaster
              start = Time.now
              begin
                result = connection.dispatch([ ISMASTER ]).documents[0]
                return result, calculate_round_trip_time(start)
              rescue Mongo::SocketError, Errno::ECONNREFUSED, SystemCallError, IOError => e
                connection.disconnect!
                return {}, calculate_round_trip_time(start)
              rescue Exception => e
                log(:debug, 'MONGODB', [ "ismaster - unexpected exception #{e} #{e.message}" ])
                raise e
              end
            end
          end
      

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            gjmurakami Gary Murakami
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: