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

Timed out attempting to check out a connection from pool

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: Connections
    • None
    • Ruby Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Hey! I upgraded mongoid from 7.4.0 to 8.1.5 which also upgraded mongo driver from 2.17.1 to 2.20.0.

      However, I see following errors frequently after upgrade: 

      Timed out attempting to check out a connection from pool for <HOST> for connection 28 after 10 sec. Connections in pool: 24 available, 1 checked out, 0 pending, 0 connections requests (max size: 256)

      In error messages, number of available connections varies (i.e 13 available, 2 available) and number of checked out connections also varies (maximum 5 checked out and mostly 1 or 2 checked out connections)  but pending and connections requests always stayed 0.

      I tried to set different values (i.e 5, 10, 100, 256) for max_connecting (maxConnecting) config but all in vain.
      maxPoolSize value is 256. I also increased it but still error persists. 
      maxIdleTimeMS value is 60 seconds. I removed it also but still error persists.

      Here is the full config:

      Mongo Connection String (MongoDB 6)

      ssl=false&maxIdleTimeMS=60000&readPreference=primaryPreferred&loadBalanced=true

      MongoID (already planned to move all possible config options to connection string): 

      client_options: &client_options
        max_pool_size: 256
        max_connecting: 100
        socket_timeout: 7200
        truncate_logs: false
        write_concern:
          w: 1

      Puma: 6.4.2

      minThreads: 5
      maxThreads: 32
      persistentTimeout: 75 // seconds 

      JRuby: 9.4.6.0

      Stack trace (error):

      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server/connection_pool.rb:1090:in `raise_check_out_timeout!'", 
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server/connection_pool.rb:1319:in `wait_for_connection'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server/connection_pool.rb:1267:in `block in retrieve_and_connect_connection'",
      "org/jruby/ext/thread/Mutex.java:171:in `synchronize'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server/connection_pool.rb:1257:in `retrieve_and_connect_connection'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server/connection_pool.rb:365:in `check_out'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server/connection_pool.rb:704:in `with_connection'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/server.rb:494:in `with_connection'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/operation/shared/op_msg_executable.rb:35:in `execute'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/cursor.rb:504:in `execute_operation'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/cursor.rb:378:in `get_more'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/cursor.rb:226:in `try_next'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/cursor.rb:168:in `block in each'",
      "org/jruby/RubyKernel.java:1707:in `loop'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/cursor.rb:167:in `each'",
      "/usr/local/bundle/gems/mongo-2.20.0/lib/mongo/collection/view/iterable.rb:85:in `each'",
      "org/jruby/RubyEnumerable.java:1082:in `inject'",
      "/usr/local/bundle/gems/mongoid-8.1.5/lib/mongoid/contextual/mongo.rb:372:in `pluck'",
        "/opt/jruby/lib/ruby/stdlib/forwardable.rb:238:in `pluck'", 

       I upgraded mongo driver to 2.20.1 also but still error persists.

      Could you please provide your valuable insights on why this error is occurring and how can we fix this?
      (this error is blocking us to implement misc. stuff)

      Thank you.

       

       

            Assignee:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Reporter:
            kaleembinkhan@gmail.com Kaleem Ullah
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: