Rails 3.2.8, delayed_job (3.0.3), delayed_job_active_record (0.3.3). Using WEBrick.
I have an initializer that asynchronously populates the cache on startup:
MyModel.delay.get_lots_of_records
MyModel.delay.get_some_other_records
MyOtherModel.delay.get_tons_of_records
MyOtherModel.delay.get_some_other_records
In the development environment, this works fine, as evidenced by the delayed_job log and the cache log.
In staging, however, sometimes 1 or 2, or sometimes none of these jobs are executed. Usually at least one, typically the same one (but not always), is executed. If I look at the delayed_jobs table after startup, I see all 4 jobs get written and then vanish 2 seconds later.
Per the recommendation here, I have
# config/initializers/delayed_job_config.rb
Delayed::Worker.destroy_failed_jobs = false
But the jobs are still being very quickly deleted without failing or executing.
If I insert breakpoints at Delayed::PerformableMethod.perform, I see that method called only if the jobs are actually executed, so the problem is upstream of that. The destroy method is called after perform, though, so I’m not sure what’s going on.
I’m looking for troubleshooting recommendations or additional diagnostic actions.
Sheepishly: I had a worker running in another environment, pointing to the same DB, that was running the jobs concurrently with my staging environment. This unintended consequence is a good reason to never share DB’s between environments.