I recently have been reading a Ruby On Rails book and have created a basic application. I went to test it, loaded up the server, but the script ran into some errors. Everytime a query is sent it says that the MySQL connection was lost when sending the query. I''m using the latest version of Ruby with MySQL 5.0 on Windows XP Pro. Can anyone help me resolve this problem. Thank you. Cheers, Josh -- 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 -~----------~----~----~----~------~----~------~--~---
Josh Gilman wrote:> I recently have been reading a Ruby On Rails book and have created a > basic application. I went to test it, loaded up the server, but the > script ran into some errors. Everytime a query is sent it says that the > MySQL connection was lost when sending the query. I''m using the latest > version of Ruby with MySQL 5.0 on Windows XP Pro. Can anyone help me > resolve this problem. Thank you. > > Cheers, > JoshCan anyone help me with this? It''s rather urgent as I am supposed to have this project finished soon. -- 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 -~----------~----~----~----~------~----~------~--~---
mcintyre.tim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-20 20:20 UTC
Re: MySQL Losing Connection?
There are some known issues, I''ve commented on this before, check out the thread: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c07682cbfb2eef60/c3604401b504de96#c3604401b504de96 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
unknown wrote:> There are some known issues, I''ve commented on this before, check out > the thread: > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c07682cbfb2eef60/c3604401b504de96#c3604401b504de96Yea I saw that thread when I was searching and tried everything everyone suggested there but had no luck. -- 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 -~----------~----~----~----~------~----~------~--~---
Josh, I was able to install the mySQL gem and that seemed to clear things up for me. However, I feel like there was something else I did but I can''t remember what it was. I''m pretty sure I posted about it, but I can''t find the post. Wes -- 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 -~----------~----~----~----~------~----~------~--~---
Even better, I wrote an email... Do the following: 1) Run "gem install mysql" and choose the latest version for win32 (should be 2.7.3) 2) Add the directory that contains libmySQL.dll to your PATH (C:\Program Files\MySQL\MySQL Server 5.0\bin) 3) Restart RadRails (obv. only if you''re running RadRails, you just need to be sure that the modified PATH is present when you start your Rails app.) After I did this, I spent close to two hours working in the app, and saw no problems. Potential Bonus: Supposedly, this driver is 10-15% faster than the pure Ruby one comes by default in Rails. Wes -- 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 -~----------~----~----~----~------~----~------~--~---
** Warning total hack** You can actually get rid of this error by making a sleeper thread that wakes up and verifies the database connection. Add this to the bottom of your environment.rb file: Thread.new{ loop{ sleep(60*60); ActiveRecord::Base.verify_active_connections! } }.priority = -10 That will wake up one an hour and verify the active database connections. Adjust the time to suit your situation. Note that this only addresses the issue with the database connection timeout. There are some other things that can cause the loas connection error that this does not fix. Cheers -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Awsome, didn''t know you could spark a thead in the enviroment, I''ll have some fun with that. An intereting note, some of the newer MySQL ruby drivers have a reconnect paramiter. Setting it to true will make the ruby reconnect after a disconnect. I haven''t tried getting rails to use it yet though. Ezra Zygmuntowicz wrote:> ** Warning total hack** > > You can actually get rid of this error by making a sleeper thread > that wakes up and verifies the database connection. Add this to the > bottom of your environment.rb file: > > > Thread.new{ loop{ sleep(60*60); > ActiveRecord::Base.verify_active_connections! } }.priority = -10 > > > That will wake up one an hour and verify the active database > connections. Adjust the time to suit your situation. Note that this > only addresses the issue with the database connection timeout. There > are some other things that can cause the loas connection error that > this does not fix. > > Cheers > > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273)-- 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 -~----------~----~----~----~------~----~------~--~---
Hello all, I realize this is an old thread but I have been having the same problem here with a new project I am working on. Rails seems to lose its connection to the mysql database when the app sits idle for just a short time, like 5-10 minutes. I looked around and haven''t seen much else on this topic. I tried the sleeper thread trick, and it works if I set the timeout to 120 seconds. Obviously a solution like this doesn''t give me that warm feeling though. My question now is: Is there any movement yet on being able to actually access the mysql reconnect setting from the rails/mongrel configuration somewhere, so that the app can just reconnect to mysql when it needs to? I''m really quite surprised that an issue like this would even be allowed into production applications written in Rails, yet people are using it all over. Is there an acceptable solution to this problem that doesn''t require a hack of the mysql driver code or a sleeper thread bandaid? Thanks in advance, Lee David Harkness wrote:> Awsome, didn''t know you could spark a thead in the enviroment, I''ll have > some fun with that. > > An intereting note, some of the newer MySQL ruby drivers have a > reconnect paramiter. > > Setting it to true will make the ruby reconnect after a disconnect. > > I haven''t tried getting rails to use it yet though. > Ezra Zygmuntowicz wrote: >> ** Warning total hack** >> >> You can actually get rid of this error by making a sleeper thread >> that wakes up and verifies the database connection. Add this to the >> bottom of your environment.rb file: >> >> >> Thread.new{ loop{ sleep(60*60); >> ActiveRecord::Base.verify_active_connections! } }.priority = -10 >> >> >> That will wake up one an hour and verify the active database >> connections. Adjust the time to suit your situation. Note that this >> only addresses the issue with the database connection timeout. There >> are some other things that can cause the loas connection error that >> this does not fix. >> >> Cheers >> >> -- Ezra Zygmuntowicz >> -- Lead Rails Evangelist >> -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org >> -- Engine Yard, Serious Rails Hosting >> -- (866) 518-YARD (9273)-- 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 -~----------~----~----~----~------~----~------~--~---
> My question now is: Is there any movement yet on being able to actually > access the mysql reconnect setting from the rails/mongrel configuration > somewhere, so that the app can just reconnect to mysql when it needs to? > I''m really quite surprised that an issue like this would even be allowed > into production applications written in Rails, yet people are using it > all over. Is there an acceptable solution to this problem that doesn''t > require a hack of the mysql driver code or a sleeper thread bandaid? > > Thanks in advance, > LeeGoogle query for rails how to set mysql to reconnect revealed this (if helpful) http://wooga.drbacchus.com/rails-and-mysql-timeouts -- 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 -~----------~----~----~----~------~----~------~--~---