简体   繁体   中英

Active Record Could not obtain a database connection within 5.000 seconds

From the last few weeks, I am seeing this error "Could not obtain a database connection within 5.000 seconds." I have tried the following solutions.

As per Sidekiq Docs I have reduced the concurrency to 10 and increased MySql DB pool size to 12. But I was still getting this error so I increased the DB pool size to 27. But still, the issue is there. Tried solutions from this and this answer. My Sidekiq server machine doesn't have any other process running which can consume AR connections. I am not spinning any threads from outside. Below are the configurations I have

Sidekiq version - 3.4.2
Rails version - 4.2.4
Active Record version - 4.2.4
Database pool size - 27
Sidekiq concurrency - 10

Any help with this will be appreciated.

I suspect it to be a connection leak from the server side.

Sidekiq::Middleware::Server::ActiveRecord is the middleware that is responsible for returning connections to the pool, after a job is completed. This should be included by default.

When you start your server with -v flag,

bundle exec sidekiq -v -C config_file

it will print all the middlewares that will be invoked. Can you check if this middleware is present in the list?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM