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

Setting min_pool_size and not max_pool_size results in connection error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.4.2
    • Affects Version/s: 2.4.0
    • Component/s: Connections
    • Labels:
      None

      If you set a `min_pool_size` to 10 and not a `max_pool_size` you do not get a client error until you make the first query. It's easy to reproduce with:

      client = Mongo::Client.new(['127.0.0.1:27017'], min_pool_size: 10)
      client[:example].find().first
      

      the error it produces:

      /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/operation/executable.rb:39:in `block in execute': undefined method `dispatch' for nil:NilClass (NoMethodError)
      Did you mean?  display
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/server/connection_pool.rb:110:in `with_connection'
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/server.rb:242:in `with_connection'
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/operation/executable.rb:35:in `execute'
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/collection/view/iterable.rb:81:in `send_initial_query'
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/collection/view/iterable.rb:41:in `block in each'
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/retryable.rb:51:in `read_with_retry'
      	from /Users/anthonyross/.gem/ruby/2.3.1/gems/mongo-2.4.1/lib/mongo/collection/view/iterable.rb:39:in `each'
      	from mongo.rb:8:in `first'
      	from mongo.rb:8:in `<main>'
      

      I would personally suggest that `max_pool_size` if not set would be `min_pool_size` + some default number (min_pool_size / 2 maybe?). I started on a patch based on this but I then realized that maybe an error should be raised if min > max.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            allcentury Anthony Ross
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: