class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter

Private Instance Methods

retryable(sql, name, &block) click to toggle source
# File lib/activerecord/mysql/reconnect/abstract_mysql_adapter_ext.rb, line 20
def retryable(sql, name, &block)
  block_with_reconnect = nil
  sql_names = [[sql, name]]
  transaction = current_transaction

  if sql =~ /\ABEGIN\z/i and transaction.is_a?(ActiveRecord::ConnectionAdapters::NullTransaction)
    def transaction.state; nil; end
  end

  Activerecord::Mysql::Reconnect.retryable(
    :proc => proc {
      (block_with_reconnect || block).call(sql_names)
    },
    :on_error => proc {
      unless block_with_reconnect
        block_with_reconnect = proc do |i|
          reconnect_without_retry!
          block.call(i)
        end
      end
    },
    :sql => sql,
    :retry_mode => Activerecord::Mysql::Reconnect.retry_mode,
    :connection => @connection
  )
end