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

Driver connects to cluster when closing stale sockets

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.8.0.rc0
    • Affects Version/s: None
    • Component/s: Connections
    • None

      The connection pool has this interesting bit of code (https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/server/connection_pool/queue.rb#L206):

              def close_stale_sockets!
      ...
                      connection.disconnect!
                      if queue.index(connection) < min_size_delta
                        begin; connection.connect!; rescue; end
                      end
      

      This causes, in my understanding, exposed by jruby:

      1. Application creates new connections at a good rate (for example, when running scram negotiation_spec).
      2. This causes there to be a large number of connections in the pool.
      3. This triggers the staleness closure logic due to min_size_delta getting exceeded.
      4. As part of closing the sockets, client establishes new connections to the server .

      This causes the aforementioned scram negotiation test to fail in jruby because instead of expected one authentication attempt I am getting 2 or 3, for users that are defined in previously executed tests.

      (This wouldn't be an issue if client instances weren't reused.)

      Exposed by jruby which, I'm guessing unlike mri, is able to concurrently run tests and do SDAM as the clients are seemingly reconnected from monitor thread.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: