Skip to content

Commit

Permalink
Retry delete when deadlocked
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjensen authored and schmitzc committed Sep 24, 2015
1 parent 270b06e commit 865a8f8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/delayed/backend/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ def reload(*args)
reset
super
end

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
Expand Down

0 comments on commit 865a8f8

Please sign in to comment.