[Ruby] Active Record looses connection to mySQL
david g
gdavidg at gmail.com
Mon May 14 12:20:47 PDT 2007
Mysql defaults to killing connections after 28800 seconds (8 hours) of
inactivity. You can try bumping up the interactive_timeout and
wait_timeout settings in your mysql config file to something more
reasonable (10 days?):
interactive_timeout=864000
wait_timeout=864000
Actually, try setting these parameters really low at first to see if
you can reproduce the exception, then you may have more confidence
that this is the correct solution path...
hth,
-david
On 5/11/07, Daevid Vincent <daevid at daevid.com> wrote:
> Thank you Corey (and Ryan) so far...
>
> It seemes to have installed just fine. Okay, now what? Do I have to modify any of my code to point to this new driver or remove the
> old mysql driver or anything?
>
> # gem list
>
> *** LOCAL GEMS ***
>
> actionmailer (1.2.5, 1.1.5)
> Service layer for easy email delivery and testing.
>
> actionpack (1.12.5, 1.11.2)
> Web-flow and rendering framework putting the VC in MVC.
>
> actionwebservice (1.1.6, 1.0.0)
> Web service support for Action Pack.
>
> activerecord (1.14.4, 1.13.2)
> Implements the ActiveRecord pattern for ORM.
>
> activesupport (1.3.1, 1.2.5)
> Support and utility classes used by the Rails framework.
>
> rails (1.1.6, 1.0.0)
> Web-application framework with template engine, control-flow layer,
> and ORM.
>
> rake (0.7.1)
> Ruby based make-like utility.
>
> sources (0.0.1)
> This package provides download sources for remote gem installation
>
> # ls /usr/lib/mysql
> libdbug.a libmysqlclient.la libmysqlclient_r.la libmystrings.a
> libheap.a libmysqlclient.so libmysqlclient_r.so libmysys.a
> libmyisam.a libmysqlclient.so.15 libmysqlclient_r.so.15 libvio.a
> libmyisammrg.a libmysqlclient.so.15.0.0 libmysqlclient_r.so.15.0.0
> libmysqlclient.a libmysqlclient_r.a libmysqld.a
>
> daevid ~ # gem install mysql -- --with-mysql-dir=/usr/lib/mysql
> Attempting local installation of 'mysql'
> Local gem file not found: mysql*.gem
> Attempting remote installation of 'mysql'
> Updating Gem source index for: http://gems.rubyforge.org
> Select which gem to install for your platform (i686-linux)
> 1. mysql 2.7.3 (mswin32)
> 2. mysql 2.7.1 (mswin32)
> 3. mysql 2.7 (ruby)
> 4. mysql 2.6 (ruby)
> 5. mysql 2.5.1 (ruby)
> 6. Cancel installation
> > 3
> Building native extensions. This could take a while...
> make: /bin/install: Command not found
> make: *** [/usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so] Error 127
> ruby extconf.rb install mysql -- --with-mysql-dir=/usr/lib/mysql
> checking for mysql_query() in -lmysqlclient... yes
> checking for mysql_ssl_set()... yes
> checking for mysql.h... no
> checking for mysql/mysql.h... yes
> creating Makefile
>
> make
> i686-pc-linux-gnu-gcc -I. -I. -I/usr/lib/ruby/1.8/i686-linux -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_MYSQL_H -I/usr/lib/mysql/include
> -fPIC -O2 -march=i686 -pipe -mfpmath=sse -mmmx -msse -fPIC -c mysql.c
> i686-pc-linux-gnu-gcc -shared -L'/usr/lib/mysql/lib' -Wl,-R'/usr/lib/mysql/lib' -L'/usr/lib' -Wl,-R'/usr/lib' -o mysql.so mysql.o
> -Wl,-R -Wl,/usr/lib -L/usr/lib -L. -lruby18 -lmysqlclient -ldl -lcrypt -lm -lc
>
> make install
> mkdir -p /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib
> /bin/install -c -m 0755 mysql.so /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib
> Successfully installed mysql-2.7
>
>
> > -----Original Message-----
> > From: ruby-bounces at zenspider.com
> > [mailto:ruby-bounces at zenspider.com] On Behalf Of Corey Jewett
> > Sent: Friday, May 11, 2007 9:53 PM
> > To: Seattle Ruby Brigade!
> > Subject: Re: [Ruby] Active Record looses connection to mySQL
> >
> > sudo gem install mysql -- --with-mysql-
> > dir=<path_to_dir_containing_libmysqlclient*>
> >
> > Something like that.
> >
> > If you just want to know if it's there then just do a gem list.
> >
> > Corey
> >
> >
> > On May 11, 2007, at 9:40 PM, Daevid Vincent wrote:
> >
> > >> -----Original Message-----
> > >> From: ruby-bounces at zenspider.com
> > >> [mailto:ruby-bounces at zenspider.com] On Behalf Of Ryan Davis
> > >> Sent: Friday, May 11, 2007 8:23 PM
> > >> To: Seattle Ruby Brigade!
> > >> Subject: Re: [Ruby] Active Record looses connection to mySQL
> > >>
> > >>
> > >> On May 11, 2007, at 18:18 , Daevid Vincent wrote:
> > >>
> > >>> It seems that after some amount of time
> > >>> (not really sure the duration, more than an hour, less
> > than a day),
> > >>> my service just shits the bed because it looses
> > connection to mySQL.
> > >>> mySQL mind you is perfectly happy and hasn't done anything wrong,
> > >>> and all my PHP pages work fantastic.
> > >>>
> > >>> If I restart my ruby application, it runs perfect... until
> > >>> AR times out again.
> > >>>
> > >>> It's extremely frustrating.
> > >>> Anyone know anything about this?
> > >>> Is it even a known issue that is to be addressed?
> > >>> Is there a work-around/patch?
> > >>
> > >> I'd put a dollar down that you're _using_ the mysql driver
> > >> that comes with rails, not the binary one.
> > >
> > > ...a glimmer of hope!
> > >
> > > How can I tell?
> > > (honestly, Evan wrote all this back-end ruby code, so I don't know
> > > a whole lot about details, but I'm happy to look up anything or
> > > search for keywords or whatever you need)
> > >
> > > I simply did an "emerge -av ruby rails" (long ago, and keep them
> > > updated) (this is Gentoo).
> > >
> > > In fact, I think I did it while you were around, helping me to
> > > learn rails way back at that old coffee shop we used to go to.
> > > Remember when you walked me through a basic scaffold demo?
> > >
> > > But I digress...
> > >
> > > How do I rectify this?
> > >
> > > Thanks Ryan.
> > >
> > > d
> > >
> > > _______________________________________________
> > > Ruby at zenspider.com - Seattle.rb non-commercial list
> > > http://www.zenspider.com/seattle.rb
> > > http://www.zenspider.com/mailman/listinfo/ruby
> >
> > _______________________________________________
> > Ruby at zenspider.com - Seattle.rb non-commercial list
> > http://www.zenspider.com/seattle.rb
> > http://www.zenspider.com/mailman/listinfo/ruby
> >
>
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
More information about the Ruby
mailing list