我在我的 rails 应用程序中使用delayed_job 和delayed_job_active_record 来执行后台作业。我们正在使用基于队列的delayed_job。为了启动延迟,我使用以下命令。
RAILS_ENV=staging script/delayed_job -i=1 --queue=queue_name start
问题是下面的查询无限触发。
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 计数为零。因此,应用程序非常慢,并且页面在很多地方都没有加载。