Re: MySQL server has gone away?

[prev] [thread] [next] [Date index for 2005/04/10]

From: harm
Subject: Re: MySQL server has gone away?
Date: 08:53 on 10 Apr 2005
On Sun, Apr 10, 2005 at 10:25:58AM +0200, Bas Schulte wrote:
> Hi all,
> 
> I've been using Apache/mod_perl/MySQL combined with Apache::DBI for 
> years, and it has been working like a charm. However, while preparing 
> for a new release of the system I built, I'm getting this:
> 
> DBD::mysql::st execute failed: MySQL server has gone away at 
> /opt/ttgp/dev/webapp/ttgp/smsclient/perl/sms line 111.
> 
> This happens after several hours of idle time in the webserver.


Bas,

looks like a connection timeout. Try:
$dbh->{'mysql_auto_reconnect'} = 1;
From the DBD::MySQL manpage:
mysql_auto_reconnect
	This attribute determines whether DBD::mysql will automatically
	reconnect to mysql if the connection be lost.

Or change the connection timeout in the mysql server.


> 
> I'm doing the general thing: use Apache::DBI (); in my startup.pl, it 
> just works, until now.
> 
> Three things are different:
> 
> - in a BEGIN block, I connect to the database, retrieve data, and then 
> generate perl code on the fly;

Under mod_perl mysql_auto_reconnect should default to 'on', but since you
connect in a BEGIN block DBI might not yet know it runs under mod_perl.

Good luck,
Harmen


        -- 
                                        The Moon is Waxing Crescent (3% of Full)

MySQL server has gone away?
Bas Schulte 08:25 on 10 Apr 2005

Re: MySQL server has gone away?
harm 08:53 on 10 Apr 2005

Re: MySQL server has gone away?
Bas Schulte 09:59 on 10 Apr 2005

Re: MySQL server has gone away?
Bas Schulte 23:18 on 10 Apr 2005

Generated at 12:49 on 16 Apr 2005 by mariachi v0.52