Last active
August 29, 2015 14:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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