sishen
2008-May-13 12:13 UTC
Why don''t enable auto-reconnect while database connection lost?
Hi. Sorry for raise an old issue. I have seen the ticket in trac but no answers found. My database is mysql and when it''s idle for a long time, the connection lost and raise some exception. I have read the mysql_adapter.rb and find it hasn''t used the reconnect policy which is allowed by the Mysql Binding. So why don''t enable this feature? Is this a design choice? I think if we allow to set "reconnect: true" in the database.yml, the thing will be better. Maybe i miss something, thanks for your all advice. Best regards. sishen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
sishen
2008-May-16 07:03 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
Should I submit a patch about this? Thanks. On May 13, 8:13 pm, sishen <yedingd...@gmail.com> wrote:> Hi. > > Sorry for raise an old issue. I have seen the ticket in trac but no answers > found. > > My database is mysql and when it''s idle for a long time, the connection lost > and raise some exception. > > I have read the mysql_adapter.rb and find it hasn''t used the reconnect > policy which is allowed by the Mysql Binding. > > So why don''t enable this feature? Is this a design choice? > > I think if we allow to set "reconnect: true" in the database.yml, the thing > will be better. > > Maybe i miss something, thanks for your all advice. > > Best regards. > > sishen--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Courtenay
2008-May-16 07:06 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
afaik Rails runs ActiveRecord::Base.verify_active_connections! before each request. Is this broken? On Fri, May 16, 2008 at 12:03 AM, sishen <YeDingding@gmail.com> wrote:> > Should I submit a patch about this? Thanks. > > On May 13, 8:13 pm, sishen <yedingd...@gmail.com> wrote: > > Hi. > > > > Sorry for raise an old issue. I have seen the ticket in trac but no > answers > > found. > > > > My database is mysql and when it''s idle for a long time, the connection > lost > > and raise some exception. > > > > I have read the mysql_adapter.rb and find it hasn''t used the reconnect > > policy which is allowed by the Mysql Binding. > > > > So why don''t enable this feature? Is this a design choice? > > > > I think if we allow to set "reconnect: true" in the database.yml, the > thing > > will be better. > > > > Maybe i miss something, thanks for your all advice. > > > > Best regards. > > > > sishen > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
sishen
2008-May-16 07:21 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
How will this work? Is this like the before_filter for each connection? I prefer this logic: begin connection.query(xx) rescue StatementInvalid reconnect end I suppose the mysql reconnect policy follow this way but i''m not sure, :) On Fri, May 16, 2008 at 3:06 PM, Courtenay <court3nay@gmail.com> wrote:> afaik Rails runs > ActiveRecord::Base.verify_active_connections! > > before each request. Is this broken? > > On Fri, May 16, 2008 at 12:03 AM, sishen <YeDingding@gmail.com> wrote: > >> >> Should I submit a patch about this? Thanks. >> >> On May 13, 8:13 pm, sishen <yedingd...@gmail.com> wrote: >> > Hi. >> > >> > Sorry for raise an old issue. I have seen the ticket in trac but no >> answers >> > found. >> > >> > My database is mysql and when it''s idle for a long time, the connection >> lost >> > and raise some exception. >> > >> > I have read the mysql_adapter.rb and find it hasn''t used the reconnect >> > policy which is allowed by the Mysql Binding. >> > >> > So why don''t enable this feature? Is this a design choice? >> > >> > I think if we allow to set "reconnect: true" in the database.yml, the >> thing >> > will be better. >> > >> > Maybe i miss something, thanks for your all advice. >> > >> > Best regards. >> > >> > sishen >> >> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-May-16 07:24 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
From what I call, Rails does not lose a connection when a StatementInvalid error is thrown. Can you prove this in a test? Sorry if I misunderstood your original post, it isn''t very clear. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
sishen
2008-May-16 09:29 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
Sorry. I haven''t described it well. I use AR only in my app. The default live time of mysql connection is 8 hours. When the connection is idle for longer than that time, the exception throws. I think there should be a reconnect policy to auto connect to the server when connection is lost, especially the mysql binding support that, right? On Fri, May 16, 2008 at 3:24 PM, Ryan Bigg (Radar) <radarlistener@gmail.com> wrote:> From what I call, Rails does not lose a connection when a StatementInvalid > error is thrown. > > Can you prove this in a test? > > Sorry if I misunderstood your original post, it isn''t very clear. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-May-17 00:15 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
> I think there should be a reconnect policy to auto connect to the server > when connection is lost, especially the mysql binding support that, right?Yeah, rails applications will do this transparently. We don''t want to have a solution that only works with mysql when the current one works for all our supported databases. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy McAnally
2008-May-17 23:54 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
I actually had 3 different people come up to me at MySQLConf and tell me their AR connections were dropping like this and not reconnecting. It might be something you want to check into (though I don''t think there''s a verifiable way to test it). I''ll try to find out more information from those guys if I can find their cards... --Jeremy On Fri, May 16, 2008 at 8:15 PM, Michael Koziarski <michael@koziarski.com> wrote:> >> I think there should be a reconnect policy to auto connect to the server >> when connection is lost, especially the mysql binding support that, right? > > Yeah, rails applications will do this transparently. We don''t want > to have a solution that only works with mysql when the current one > works for all our supported databases. > > -- > Cheers > > Koz > > > >-- http://jeremymcanally.com/ http://entp.com Read my books: Ruby in Practice (http://manning.com/mcanally/) My free Ruby e-book (http://humblelittlerubybook.com/) Or, my blogs: http://mrneighborly.com http://rubyinpractice.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Pratik
2008-May-17 23:56 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
The catch is, if someone is running AR in daemonized env. outside actionpack, they gotta call verify_active_connections! manually. On Sun, May 18, 2008 at 12:54 AM, Jeremy McAnally <jeremymcanally@gmail.com> wrote:> > I actually had 3 different people come up to me at MySQLConf and tell > me their AR connections were dropping like this and not reconnecting. > It might be something you want to check into (though I don''t think > there''s a verifiable way to test it). > > I''ll try to find out more information from those guys if I can find > their cards... > > --Jeremy > > On Fri, May 16, 2008 at 8:15 PM, Michael Koziarski > <michael@koziarski.com> wrote: >> >>> I think there should be a reconnect policy to auto connect to the server >>> when connection is lost, especially the mysql binding support that, right? >> >> Yeah, rails applications will do this transparently. We don''t want >> to have a solution that only works with mysql when the current one >> works for all our supported databases. >> >> -- >> Cheers >> >> Koz >> >> > >> > > > > -- > http://jeremymcanally.com/ > http://entp.com > > Read my books: > Ruby in Practice (http://manning.com/mcanally/) > My free Ruby e-book (http://humblelittlerubybook.com/) > > Or, my blogs: > http://mrneighborly.com > http://rubyinpractice.com > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Courtenay
2008-May-18 05:02 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
AR connections timeout and drop, that''s how it is. Rails fixes this in a filter. I believe it''s documented. That''s why on our tt AIM bot I have to verify connections before each access (but you knew that, jeremy :P ). As lifo says. On Sat, May 17, 2008 at 4:56 PM, Pratik <pratiknaik@gmail.com> wrote:> > The catch is, if someone is running AR in daemonized env. outside > actionpack, they gotta call verify_active_connections! manually. > > On Sun, May 18, 2008 at 12:54 AM, Jeremy McAnally > <jeremymcanally@gmail.com> wrote: > > > > I actually had 3 different people come up to me at MySQLConf and tell > > me their AR connections were dropping like this and not reconnecting. > > It might be something you want to check into (though I don''t think > > there''s a verifiable way to test it). > > > > I''ll try to find out more information from those guys if I can find > > their cards... > > > > --Jeremy > > > > On Fri, May 16, 2008 at 8:15 PM, Michael Koziarski > > <michael@koziarski.com> wrote: > >> > >>> I think there should be a reconnect policy to auto connect to the > server > >>> when connection is lost, especially the mysql binding support that, > right? > >> > >> Yeah, rails applications will do this transparently. We don''t want > >> to have a solution that only works with mysql when the current one > >> works for all our supported databases. > >> > >> -- > >> Cheers > >> > >> Koz > >> > >> > > >> > > > > > > > > -- > > http://jeremymcanally.com/ > > http://entp.com > > > > Read my books: > > Ruby in Practice (http://manning.com/mcanally/) > > My free Ruby e-book (http://humblelittlerubybook.com/) > > > > Or, my blogs: > > http://mrneighborly.com > > http://rubyinpractice.com > > > > > > > > > > > -- > Cheers! > - Pratik > http://m.onkey.org > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-May-18 06:03 UTC
Re: Why don''t enable auto-reconnect while database connection lost?
> AR connections timeout and drop, that''s how it is. Rails fixes this in a > filter. I believe it''s documented. > That''s why on our tt AIM bot I have to verify connections before each access > (but you knew that, jeremy :P ). As lifo says.Having said that, there''s no reason why the adapter *couldn''t* support a reconnect option, if it''s in the mysql client lib. I''d be happy to take patches for it. However I certainly wouldn''t want to roll our own reconnect-on-error thing, retrying sql statements is a great way to lose friends and invalidate data.> On Sat, May 17, 2008 at 4:56 PM, Pratik <pratiknaik@gmail.com> wrote: >> >> The catch is, if someone is running AR in daemonized env. outside >> actionpack, they gotta call verify_active_connections! manually. >> >> On Sun, May 18, 2008 at 12:54 AM, Jeremy McAnally >> <jeremymcanally@gmail.com> wrote: >> > >> > I actually had 3 different people come up to me at MySQLConf and tell >> > me their AR connections were dropping like this and not reconnecting. >> > It might be something you want to check into (though I don''t think >> > there''s a verifiable way to test it). >> > >> > I''ll try to find out more information from those guys if I can find >> > their cards... >> > >> > --Jeremy >> > >> > On Fri, May 16, 2008 at 8:15 PM, Michael Koziarski >> > <michael@koziarski.com> wrote: >> >> >> >>> I think there should be a reconnect policy to auto connect to the >> >>> server >> >>> when connection is lost, especially the mysql binding support that, >> >>> right? >> >> >> >> Yeah, rails applications will do this transparently. We don''t want >> >> to have a solution that only works with mysql when the current one >> >> works for all our supported databases. >> >> >> >> -- >> >> Cheers >> >> >> >> Koz >> >> >> >> > >> >> >> > >> > >> > >> > -- >> > http://jeremymcanally.com/ >> > http://entp.com >> > >> > Read my books: >> > Ruby in Practice (http://manning.com/mcanally/) >> > My free Ruby e-book (http://humblelittlerubybook.com/) >> > >> > Or, my blogs: >> > http://mrneighborly.com >> > http://rubyinpractice.com >> > >> > > >> > >> >> >> >> -- >> Cheers! >> - Pratik >> http://m.onkey.org >> >> > > > > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---