-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: Connections
-
None
-
Ruby Drivers
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.
- duplicates
-
RUBY-3463 Cursor does not retain connection in load balanced topology.
- Closed