It happens when MySQL closes the open connection after 8 hours (By default) or upon restart ing MySQL.
I tried various solutions (None of these worked):
1. ActiveRecord::Base.verification_timeout = 14400
2. Stale database connections should be handled gracefully
3. Irc.freenode.net – #RubyOnRails (Totally crap when you need help!)
4. MySQL connection timeout setting
Finally, I tried reproducing the error in Windows and realized that it didn’t crash!
Hence, I looked into Mysql.rb code and saw the following (for rails 1.2.3, activerecord 1.15.3):
Win32 => VERSION = “4.0-ruby-0.2.6-plus-changes”
Linux => VERSION = “4.0-ruby-0.2.5”
Go to Mysql.rb => def write(data)
Add the following to the end of the method
errno = Error::CR_SERVER_LOST
raise Error::new(errno, Error::err(errno))
And VOILA a 2 min fix for 3 days of diagnosis…