lib/ledgerizer/extensions/locking_extensions.rb
def with_restart_on_deadlock
      yield
    rescue ActiveRecord::StatementInvalid => e
      if e.message =~ /deadlock/i || e.message =~ /database is locked/i
        ActiveSupport::Notifications.publish('deadlock_restart.ledgerizer', exception: e)

        raise ActiveRecord::RestartTransaction
      else
        raise
      end
    end
# Execute the given block, and retry the current restartable transaction if a
# MySQL deadlock occurs.
Execute the given block, and retry the current restartable transaction if a
MySQL deadlock occurs.
Execute the given block and retry the current restartable transaction if a MySQL deadlock occurs .
def with_restart_on_deadlock
      yield
    rescue ActiveRecord::StatementInvalid => e
      if e.message =~ /deadlock/i || e.message =~ /database is locked/i
        ActiveSupport::Notifications.publish('deadlock_restart.ledgerizer', exception: e)
        raise ActiveRecord::RestartTransaction
      else
        raise
      end
    end
def with_restart_on_deadlock yield rescue ActiveRecord :: StatementInvalid => e if e . message =~ / deadlock /i || e . message =~ / database is locked /i ActiveSupport :: Notifications . publish ( 'deadlock_restart.ledgerizer' , exception : e ) raise ActiveRecord :: RestartTransaction else raise end end
Execute the given block, and retry the current restartable transaction if a
MySQL deadlock occurs.
Execute the given block and retry the current restartable transaction if a MySQL deadlock occurs .