Getting a MySQL deadlock when running RailsCron

I’m using RailsCron, and it’s working out very well for me. However,
I’m having one problem right now.

I use the acts_as_background on one of my model objects. In order to
get it to add the cron job to the table, I have to make sure the model
is loaded in environment.rb.

MyObject.load

However, I’m running 2-3 fcgi process on my server. Most of the time
when I start lighty, I get a mysql deadlock error as the
acts_as_background tries to delete and re-add itself to the rails_cron
table:

rails/current/public/…/config/…/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
`log’: Mysql::Error: Deadlock found when trying to get lock; try
restarting transaction: DELETE FROM rails_crons
(ActiveRecord::StatementInvalid)

How can I get around this? As I understand it, each fcgi starts up
it’s own environment, so each it trying to add the acts_as_background
tasks to the database, and they are deadlocking each other.

Any suggestions?

Great plugin by the way - much prefer using it to normal cron!

Thanks,
Brett

Bump…any ideas?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs