[英]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."从过去几周开始,我看到此错误“无法在 5.000 秒内获得数据库连接”。 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.根据 Sidekiq Docs,我已将并发性降低到 10,并将 MySql 数据库池大小增加到 12。但我仍然收到此错误,因此我将数据库池大小增加到 27。但问题仍然存在。 Tried solutions from this and this answer.
从这个和这个答案中尝试了解决方案。 My Sidekiq server machine doesn't have any other process running which can consume AR connections.
我的 Sidekiq 服务器机器没有运行任何其他可以使用 AR 连接的进程。 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. Sidekiq::Middleware::Server::ActiveRecord
是负责在作业完成后将连接返回到池的中间件。 This should be included by default.默认情况下应包含此内容。
When you start your server with -v
flag,当您使用
-v
标志启动服务器时,
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?
你能检查一下这个中间件是否存在于列表中吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.