X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/77303f1e5ac466d59129f6cf083e5f6d6ac09288..61123eaeb4c59fc4a7cc64fad8fe4bc2645da38d:/vendor/plugins/deadlock_retry/lib/deadlock_retry.rb diff --git a/vendor/plugins/deadlock_retry/lib/deadlock_retry.rb b/vendor/plugins/deadlock_retry/lib/deadlock_retry.rb index 413cb823c..f287c4e67 100644 --- a/vendor/plugins/deadlock_retry/lib/deadlock_retry.rb +++ b/vendor/plugins/deadlock_retry/lib/deadlock_retry.rb @@ -33,7 +33,8 @@ module DeadlockRetry module ClassMethods DEADLOCK_ERROR_MESSAGES = [ "Deadlock found when trying to get lock", - "Lock wait timeout exceeded" + "Lock wait timeout exceeded", + "deadlock detected" ] MAXIMUM_RETRIES_ON_DEADLOCK = 3 @@ -44,6 +45,7 @@ module DeadlockRetry begin transaction_without_deadlock_handling(*objects, &block) rescue ActiveRecord::StatementInvalid => error + raise unless connection.open_transactions.zero? if DEADLOCK_ERROR_MESSAGES.any? { |msg| error.message =~ /#{Regexp.escape(msg)}/ } raise if retry_count >= MAXIMUM_RETRIES_ON_DEADLOCK retry_count += 1