I get the following warning with Rails 4 and Sidekiq on os x on development
10:13:39 worker.1 | 2014-09-22T07:13:39.857Z 86981 TID-oug0oog10 WARN: could not obtain a database connection within 5.000 seconds (waited 5.002 seconds) 10:13:39 worker.1 | 2014-09-22T07:13:39.857Z 86981 TID-oug0oog10 WARN: /Users/me/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block in wait_poll'
I read other answers that say to reduce the concurrency I give to sidekiq to allow more for other things, but with
worker: bundle exec sidekiq -c 10
it still doesn't work
I am using Postgres.app
What should the numbers/concurrency be in localhost?
I set database pool to sidekiq concurrency and now it works for me.
bundle exec sidekiq -c 10
in my database.yml
development: adapter: postgresql ... host: localhost pool: 10
The probem is related to the fact that database pool should be 'sidekiq_concurrency' + 2. If you put this into your sidekiq initializer you will solve the problem in general:
Sidekiq.configure_server do |config| config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env] config['pool'] = Sidekiq.options[:concurrency] + 2 ActiveRecord::Base.establish_connection(config) Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With