que-rb/que

all pooled connections were in use

dima4p opened this issue · 3 comments

postgresql-12.3
ruby '2.7.1'
que (1.0.0.beta4)
max_connections = 100

I have started 5 DelayedJob. After a while they failed with this message:

#<Thread:0x0000000005380c20 /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/worker.rb:41 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
22: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/worker.rb:46:in `block in initialize'
21: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/worker.rb:65:in `work_loop'
20: from /usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/forwardable.rb:235:in `execute'
19: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/connection_pool.rb:57:in `execute'
18: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/connection_pool.rb:18:in `checkout'
17: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/active_record/connection.rb:11:in `checkout'
16: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/active_record/connection.rb:23:in `wrap_in_rails_executor' 
15: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activesupport-6.0.3.6/lib/active_support/execution_wrapper.rb:88:in `wrap'
14: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/que-1.0.0.beta4/lib/que/active_record/connection.rb:12:in `block in checkout'
13: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:468:in `with_connection'
12: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
11: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
10: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:875:in `acquire_connection'
9: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:166:in `poll'
8: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:175:in `synchronize'
7: from /usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/monitor.rb:202:in `mon_synchronize'
6: from /usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'
5: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:166:in `block in poll'
4: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:297:in `internal_poll'
3: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:171:in `internal_poll'
2: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:210:in `wait_poll'
1: from /usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:210:in `loop'
/usr/local/rvm/gems/ruby-2.7.1@logan/gems/activerecord-6.0.3.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:221:in `block in wait_poll': could not obtain a connection from the pool within 5.000 seconds (waited 5.002 seconds); all pooled connections were in use (ActiveRecord::ConnectionTimeoutError)

I tried to increase the max_connections to 200 but the result is the same.

Is there a solution?

What does your database.yml say? The default value for pool in ActiveRecord is 5 and you might need to increase it. S.a. https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html

What does your database.yml say? The default value for pool in ActiveRecord is 5 and you might need to increase it. S.a. https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html

A good question. Thanks. I'll try.

Closing this @dima4p. Feel free to re-open if still an issue.