Revision: 4318
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 26, 2007 01:01 by esad
Initial Code
# Patch Mysql adapter so that it reconnects after discovering an lost connection error module ActiveRecord::ConnectionAdapters class MysqlAdapter alias :orig_execute :execute def execute(sql,name=nil) orig_execute(sql,name) rescue ActiveRecord::StatementInvalid => exception if LOST_CONNECTION_ERROR_MESSAGES.any? { |msg| exception.message. =~ /#{msg}/ } reconnect! retry else raise end end end end
Initial URL
Initial Description
Initial Title
A monkey-patch to activerecord to reconnect after it loses the connection to the mysql server
Initial Tags
mysql, rails
Initial Language
Ruby