I have a rails app serving up XML on an infrequent basis. This is being run with mongrel and mysql. I''ve found that if the app does not get exercised for longer than a few hours it goes dead ("Lost Connection to MySQL") and starts throwing Errno::EPIPE errors. It seems that the mysql connection gets timed out for inactivity or something like that. It can be restarted with ''mongrel_rails restart -P /path/to/the/mongrel.pid'' ... but that''s not really a solution. My collaborator expects the app to be there when he is working on his part (and I am most likely not around). My question is: What can I do to prevent this problem from occurring in the 1st place? (e.g. don''t time me out!!). Failing that, is there some code I can insert somewhere to automatically remake the Db connection? -- Mike Berrow -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Sep-27 09:34 UTC
Re: Preventing Mongrel/Mysql Errno::EPIPE exceptions
On Sep 27, 12:43 am, Mike Berrow <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> My question is: > > What can I do to prevent this problem from occurring in the 1st place? > (e.g. don''t time me out!!). > > Failing that, is there some code I can insert somewhere to automatically > remake the Db connection? >change the value of config.active_record.verification_timeout to something below whatever timeout your mysql timeout is set to. Fred> -- Mike Berrow > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> change the value of config.active_record.verification_timeout to > something below whatever timeout your mysql timeout is set to.It was also suggested elsewhere http://stackoverflow.com/questions/131481/preventing-mongrelmysql-errnoepipe-exceptions that I do the following: (full advice is at https://boxpanel.blueboxgrp.com/public/the_vault/index.php/Mongrel_/_MySQL_Timeout ) # Set the verification timeout so that the mongrel connection won''t die if left alone (1 week) ActiveRecord::Base.verification_timeout = 604800 # Keep Connection Open Thread.new { loop { ActiveRecord::Base.verify_active_connections!; 1800.times { sleep 2 } } }.priority = -10 and also (in mysql.cnf) # Fix for bug where mongrel doesn''t close timed-out connections: Just don''t time out connections. wait_timeout= 3456000 Why is that thread calling verify_active_connections! needed if verification_timeout < wait_timeout ? -- Mike Berrow -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---