delay_job更新查询无限运行 [英] delayed_job update query is running infinitely
问题描述
我在我的Rails应用程序中使用delay_job和delay_job_active_record来执行后台作业.我们正在使用基于队列的delay_job.为了启动延迟,我正在使用以下命令.
I am using delayed_job and delayed_job_active_record for back ground job execution in my rails application. We are using queue based delayed_job. For starting the delayed I am using the following command.
RAILS_ENV=staging script/delayed_job -i=1 --queue=queue_name start
下面的问题是查询无限触发.
The problem is below query is firing infinitely.
SQL (0.4ms) UPDATE `delayed_jobs` SET `locked_at` = '2013-04-16 09:27:23', `locked_by` = 'delayed_job.=2 host:ip-10-204-210-77 pid:2168' WHERE `delayed_jobs`.`queue` IN ('queue_name') AND ((run_at <= '2013-04-16 09:27:23' AND (locked_at IS NULL OR locked_at < '2013-04-16 05:27:23') OR locked_by = 'delayed_job.=2 host:ip-10-204-210-77 pid:2168') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1
并且delay_job计数为零.因此,该应用程序运行非常缓慢,并且页面无法在很多地方加载.
And the delayed_job count is zero. Because of this the application is very slow and the pages are not loading in many places.
推荐答案
我认为您的意思是 delayed_job
民意调查太频繁了(顺便说一下,每个 5
秒))-我知道这填满了您的日志,并且似乎"infinite" ..:)
I think what you meant is that delayed_job
polls too frequently (which by the way is every 5
seconds by default) - I know that fills up your log, and seems "infinite".. :)
如果这就是您的意思,那么我建议您运行无用宝石.它只会根据需要启动 delayed_job
.许多人使用它来防止他们的 Heroku 工人dynos处于空闲状态,但是在中它也能正常工作开发
模式.
If that is what you meant, then I suggest you run the workless gem. It will only start delayed_job
on a per need basis. Many people use it to keep their Heroku worker dynos from running idle, but it works just as well in development
mode.
请注意,如果您使用的是 delayed_job_active_record ,则还需要添加 gem'daemons'
到您的 Gemfile
( daemons ).请参阅 delayedjob
的正在运行的作业"部分.
Note that if you are using delayed_job_active_record, you also need to add gem 'daemons'
to your Gemfile
(daemons). See the Running Jobs section of delayed_job
.
因此,您的 Gemfile
将包含:
gem 'delayed_job_active_record'
gem 'daemons'
gem 'workless'
如果您需要更多指导,请在下面的评论中告诉我.
If you need more guidance, let me know in the comments below.
这篇关于delay_job更新查询无限运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!