简体   繁体   English

Sidekiq工作忙于使用postgres和rails 5

[英]Sidekiq jobs stuck in busy with postgres & rails 5

I got some "randomly" jobs stuck in busy state in sidekiq for hours (even days). 我在sidekiq中忙了几个小时(甚至几天)而处于繁忙状态的“随机”工作。 I am not able to reproduce it in my local dev environment, but in production DB (azure db service) got stuck. 我无法在本地开发环境中复制它,但是在生产数据库(azure db服务)中卡住了。

When I send TTIN to SQ I get this: 当我将TTIN发送给SQ时,会收到以下消息:

2017-07-24T09:13:47.000Z [1]: Thread TID-qf9sw processor                                                                                           [1673/1844]
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `async_
exec'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `block 
in exec_no_cache'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/abstract_adapter.rb:590:in `block in
 log'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `exec_n
o_cache'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:587:in `execut
e_and_clear'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:10
3:in `exec_query'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/abstract/database_statements.rb:373:
in `select'
2017-07-24T09:13:47.000Z [1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.4/lib/active_record/connection_adapters/abstract/database_statements.rb:41:i
n `select_all'

I can see in PG that there lot of idle connections, but they get used over time, so seems like normal pool behavior. 我在PG中可以看到有很多空闲连接,但是它们会随着时间的推移而被使用,因此看起来像是正常的池行为。

Running same process "by hand" runs instantly so seem not to be a code problem. “手动”运行同一进程会立即运行,因此似乎不是代码问题。 I am also using #with_connection but didn't help. 我也使用#with_connection但没有帮助。

I am using 2 docker containers, one running rails server (puma) other running just sidekiq. 我正在使用2个Docker容器,一个正在运行的Rails服务器(puma),另一个仅在运行sidekiq。

I tried tweaking the variables and reaper setting in database.yml but didn't solve the problem. 我尝试调整database.yml中的变量和收割者设置,但没有解决问题。

Any clue will be very welcome. 任何线索将非常受欢迎。

What are the jobs doing? 从事什么工作? Are they creating deadlocks at a db level or other somehow? 他们是在数据库级别还是以其他方式创建死锁? Putting some kind of debug log in the job will help you understand where within the job it's getting stuck. 在作业中放入某种调试日志将有助于您了解作业中的卡住位置。 Sidekiq has timeout and uniqueness settings (may require licensing) which may help manage the issue but not fix the root. Sidekiq具有超时和唯一性设置(可能需要许可),这可能有助于管理问题,但不能解决根问题。

因此,这是Azure服务端的“未定义”问题,感谢您的尝试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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