Files | Admin

Notes:

Release Name: 0.0.1

Notes: Has your Rails app ever thrown the 'Lost Connection to MySQL server' exception? I love that error. How about 'MySQL server has gone away?' That's a good one too. If you're a fan of these exceptions then stop reading now because I'm about to make them go away. Rails is set up to handle database connections in such a way that the likelihood of hitting these errors increases with the size of your code base. ActiveRecord maintains one database connection per model. If you use that database command often enough then it times out resulting in the errors listed above. You can set the timeout interval in your environment.rb with this: ActiveRecord::Base.verification_timeout = 14400 If your app only has a handful of models and you hit actions that trigger activity on each model.s connection frequently enough then bumping up the interval in the above config might just be a good enough solution for you. But when you keep adding models to your app to keep up with feature requests then you.ll eventually have a user execute a code path on a process whose database connection has timed out. We have 123 models at Zvents and counting. We got to the point where Increasing the verification_timeout wasn't really helping - we still hit a handful of connections timeouts on models that didn't receive a lot of usage (backend stuff mostly). The solution, quite simply, is to have the database adapter reconnect to the database when it detects a lost connection. It's not an original or groundbreaking idea, but I couldn't find any plugins so I threw together the mysql_retry_lost_connection plugin.


Changes: