Hi, I have a function which when called triggers a thread. The function returns after starting the thread. Thread should access database update few tables and then should end. But I am getting an error when Thread tries to access the database: Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m Do i have to open up a new database connection for threads? If so how do I do it? Any suggestions? Regards, Sandeep G -- 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 -~----------~----~----~----~------~----~------~--~---
And if i don''t invoke this thread, whole app works fine. So MYSQL connection is intact in main thread, but on spawned thread hits the block with: Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m Sandeep Gudibanda wrote:> Hi, > > I have a function which when called triggers a thread. The function > returns after starting the thread. > > Thread should access database update few tables and then should end. But > I am getting an error when Thread tries to access the database: > > Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m > > Do i have to open up a new database connection for threads? If so how do > I do it? > > Any suggestions? > > Regards, > Sandeep G-- 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 -~----------~----~----~----~------~----~------~--~---
On Mar 26, 6:34 pm, Sandeep Gudibanda <rails-mailing-l...@andreas- s.net> wrote:> And if i don''t invoke this thread, whole app works fine. So MYSQL > connection is intact in main thread, but on spawned thread hits the > block with: > Mysql::Error: Lost connection to MySQL server during query: BEGIN [0mHave you set ActiveRecord::Base.allow_concurency to true ? Fred> > > > Sandeep Gudibanda wrote: > > Hi, > > > I have a function which when called triggers a thread. The function > > returns after starting the thread. > > > Thread should access database update few tables and then should end. But > > I am getting an error when Thread tries to access the database: > > > Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m > > > Do i have to open up a new database connection for threads? If so how do > > I do it? > > > Any suggestions? > > > Regards, > > Sandeep G > > -- > 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 -~----------~----~----~----~------~----~------~--~---
AFAIK this is a problem with the mysql connector supplied with Rails. Install mysql gem and then use it in the thread to connect to mysql. MySQL new connections are very light weight and hence there should be no problem with opening extra connection(I may be wrong here) On Thu, Mar 27, 2008 at 12:41 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Mar 26, 6:34 pm, Sandeep Gudibanda <rails-mailing-l...@andreas- > s.net> wrote: > > And if i don''t invoke this thread, whole app works fine. So MYSQL > > connection is intact in main thread, but on spawned thread hits the > > block with: > > Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m > > Have you set ActiveRecord::Base.allow_concurency to true ? > > Fred > > > > > > > > Sandeep Gudibanda wrote: > > > Hi, > > > > > I have a function which when called triggers a thread. The function > > > returns after starting the thread. > > > > > Thread should access database update few tables and then should end. > But > > > I am getting an error when Thread tries to access the database: > > > > > Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m > > > > > Do i have to open up a new database connection for threads? If so how > do > > > I do it? > > > > > Any suggestions? > > > > > Regards, > > > Sandeep G > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Mar 26, 6:34�pm, Sandeep Gudibanda <rails-mailing-l...@andreas- > s.net> wrote: >> And if i don''t invoke this thread, whole app works fine. So MYSQL >> connection is intact in main thread, but on spawned thread hits the >> block with: >> Mysql::Error: Lost connection to MySQL server during query: BEGIN [0m > > Have you set ActiveRecord::Base.allow_concurency to true ? > > FredIf I set this in environment.rb, app fails totally :( Below is the error. #<NoMethodError: undefined method `requires_reloading?'' for {}:Hash> I tried doing , ActiveRecord::Base.establish_connection with in thread. Though it doesn''t fail when i do so, i dont see any actions being performed on database though. I am totally lost! How do I set this allow_concurrency? My develoment machine is windows and I am using webrick. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Piyush Ranjan wrote:> AFAIK this is a problem with the mysql connector supplied with Rails. > Install mysql gem and then use it in the thread to connect to mysql. > MySQL > new connections are very light weight and hence there should be no > problem > with opening extra connection(I may be wrong here) > > On Thu, Mar 27, 2008 at 12:41 AM, Frederick Cheung <Hi Piyush, I installed mysql-gem (win32) . Do I need to do some intialization in the thread before accessing the database? Regards, Sandeep G -- 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 -~----------~----~----~----~------~----~------~--~---
yes you need to do establish_connection On Thu, Mar 27, 2008 at 11:40 AM, Sandeep Gudibanda < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Piyush Ranjan wrote: > > AFAIK this is a problem with the mysql connector supplied with Rails. > > Install mysql gem and then use it in the thread to connect to mysql. > > MySQL > > new connections are very light weight and hence there should be no > > problem > > with opening extra connection(I may be wrong here) > > > > On Thu, Mar 27, 2008 at 12:41 AM, Frederick Cheung < > > Hi Piyush, > > I installed mysql-gem (win32) . Do I need to do some intialization in > the thread before accessing the database? > > Regards, > Sandeep G > -- > 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 -~----------~----~----~----~------~----~------~--~---
Is there an easy way to tell if your app is using the mysql connected supplied with rails? or the compiled version? Piyush Ranjan wrote:> AFAIK this is a problem with the mysql connector supplied with Rails. > Install mysql gem and then use it in the thread to connect to mysql. > MySQL > new connections are very light weight and hence there should be no > problem > with opening extra connection(I may be wrong here) > > On Thu, Mar 27, 2008 at 12:41 AM, Frederick Cheung <-- 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 -~----------~----~----~----~------~----~------~--~---