I've looked a bit more at this. The same issue can be recreated by restarting the mysql server after a connection has been made.
If you add a before filter to the top of Application which calls ActiveRecord::Base#verify_active_connections! this fixes the problem (when the SQL server is restarted anyway - and I assume it will work for the MySQL wait_timeout issue too). So by calling verify_active_connections within the dispatch loop would appear to solve the problem. As merb will currently fail if the MySQL server is restarted I think this is a bug? I've worked up a simple patch to merb_activerecord that appears to solve this problem for me. It calls ActiveRecord::Base#verify_active_connections! before the action is dispatched. I'm not sure if this is the right way to go about it, and I'm not sure how I can spec this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/merb?hl=en -~----------~----~----~----~------~----~------~--~---
0001-adding-fix-for-AR-records-going-stale.patch
Description: Binary data
Steve On 28 Oct 2008, at 12:16, Steve Tooke wrote: > I'm not sure. After a bit of research... > > ActiveRecord::Base has a verification_timeout attribute, which is > used to verify db connections, and ensure that they don't hit the > MySQL wait_timeout. > > verification_timeout is only used by > ActiveRecord::Base#verify_active_connections! so it does nothing by > itself. > > Rails calls this method in Dispatcher before dispatch > > http://github.com/rails/rails/tree/master/actionpack/lib/action_controller/dispatcher.rb#L26 > > The merb fix is to start a thread to run this method at regular > intervals, this doesn't seem to be working as expected. Nick > Dufresne in the LH ticket shows that running in the thread AR > reports no active connections. > > The fix that Martyn suggested is essentially the same idea, just > adding it as before filter on Application. > > Is there a way that merb_activerecord can inject calling > ActiveRecord::Base#verify_active_connections! into the dispatch > process? > > Steve > > On 28 Oct 2008, at 11:09, Julian Leviston wrote: > >> >> It's not actually a Merb issue. >> >> It happens with PHP, too. It's a mysql/os-level issue. Google it. >> >> Julian.
