Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjensen/5ebe7930607b76a3c84d to your computer and use it in GitHub Desktop.
Save aaronjensen/5ebe7930607b76a3c84d to your computer and use it in GitHub Desktop.
delayed_job_active_record retry fix monkey patch see: https://github.com/collectiveidea/delayed_job_active_record/pull/91
require 'delayed/backend/active_record'
module Delayed
module Backend
module ActiveRecord
class Job < ::ActiveRecord::Base
def destroy
retries = 0
begin
super
rescue ::ActiveRecord::StatementInvalid => e
if e.message =~ /Deadlock found when trying to get lock/ && retries < 100
retries +=1
retry
else
raise
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment