[jifty-devel] MySQL: Transparent reconnect

Wolfgang Kinkeldei wolfgang at kinkeldei.de
Tue Sep 5 07:38:17 EDT 2006


Am 05.09.2006 um 10:31 schrieb Thomas Themel:

> Hi,
>
> my Jifty web application has now been deployed, and because it's a  
> small
> application used infrequently by only a few people, I get a lot of  
> MySQL
> timeouts. Jifty reacts to this by logging
>
> [Tue Sep 05 10:18:29 2006] [error] [client 85.124.169.111] FastCGI:
> server "/home/www/ql.themel.com/bin/jifty" stderr: DBD::mysql::st  
> execute
> failed: MySQL server has gone away at
> /usr/local/share/perl/5.8.4/Jifty/DBI/Handle.pm line 468.
>
> DBD::mysql actually has a transparent reconnect feature that it  
> disables
> by default, unless the environment variables MOD_PERL or
> GATEWAY_INTERFACE are set. It can be turned on by setting
> $db->{mysql_auto_reconnect} = 1 ; It would be really useful for me to
> have this in Jifty. After a quick look at the source, I didn't see an
> obvious hook to change the initialization of Jifty::DBI::Handle::mysql
> objects, and so I thought I'd ask whether

There is a hook, however.

> - Jifty should set GATEWAY_INTERFACE, at least in fastcgi mode?
> - it would be a good idea to add handle-specific connect or new  
> methods?

You can obtain the DBI handle using:
   my $dbh = Jifty->handle->dbh;

If you build a class named as your application and place a "start"  
method inside, this method will get called after the initialization  
of your app (this is the final step in Jifty's "new" method). Inside  
this sub you might set the "mysql_auto_reconnect" on your DBI handle  
you might obtain like above.


Regards,

Wolfgang Kinkeldei

-- 

' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x
'( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+||
' > ^ < ' .q<!-- Wolfgang Kinkeldei - mailto:wolfgang at kinkeldei.de -->






More information about the jifty-devel mailing list