MySQL上的delayed_job:'这个版本的MySQL还不支持'LIMIT& IN / ALL / ANY / SOME子查询'

时间:2013-02-11 10:52:27

标签: mysql ruby-on-rails ruby ruby-on-rails-3 delayed-job

尝试在MySQL环境中部署Rails 3应用程序,但遇到了delayed_job(v3.0.5)gem的问题。

db:migrate似乎没问题:

==  CreateDelayedJobs: migrating ==============================================
-- create_table(:delayed_jobs, {:force=>true})
   -> 0.0055s
-- add_index(:delayed_jobs, [:priority, :run_at], {:name=>"delayed_jobs_priority"})
   -> 0.0040s
==  CreateDelayedJobs: migrated (0.0096s) =====================================

但是尝试script/delayed_job run(非常长的查询警告):

delayed_job: process with pid 10713 started.
Mysql2::Error: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery': UPDATE `delayed_jobs` SET `locked_at` = '2013-02-11 10:43:13', `locked_by` = 'delayed_job                       host:dev pid:10713' WHERE `delayed_jobs`.`id` IN (SELECT  id FROM `delayed_jobs`  WHERE ((run_at <= '2013-02-11 10:43:13' AND (locked_at IS NULL OR locked_at < '2013-02-11 06:4                      3:13') OR locked_by = 'delayed_job host:dev pid:10713') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1 FOR UPDATE) AND ((run_at <= '2013-02-11 10:43:13' AND (l                      ocked_at IS NULL OR locked_at < '2013-02-11 06:43:13') OR locked_by = 'delayed_job host:dev pid:10713') AND failed_at IS NULL)

我可以确认这些表都在那里并且是空的。

我试过:MySQL 5.1和5.5以及每个的Percona和MariaDB。我试过Linux和Windows机器。

令我难以置信的是,这在sqlite3上工作得很好,但不适用于MySQL。考虑到宝石的受欢迎程度,我希望我在某个地方犯了一个错误,而不是它在MySQL上破坏的可能性。

感谢。

-

我在Postgres 9.1中测试过,它运行正常......

1 个答案:

答案 0 :(得分:1)

我有同样的问题并发现了这一点。看来你现在需要使用旧版本。他们昨天对活跃的唱片宝石做了一些更新。

https://github.com/collectiveidea/delayed_job_active_record/issues/32