Class: ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql_stay_connected.rb

Instance Method Summary collapse

Instance Method Details

#execute(*args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mysql_stay_connected.rb', line 20

def execute(*args)
  execute_without_retry(*args)
rescue ActiveRecord::StatementInvalid => e
  if e.message =~ /server has gone away/i
    warn "Server timed out, retrying"
    reconnect!
    retry
  else
    raise e
  end
end

#execute_without_retryObject



18
# File 'lib/mysql_stay_connected.rb', line 18

alias_method :execute_without_retry, :execute