You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bas Schulte <bs...@zeelandnet.nl> on 2005/04/10 10:25:58 UTC

MySQL server has gone away?

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.

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;
- server is a slackware 10.1 box instead of a redhat 9 box;
- MySQL is 4.1.10a, compiled from source i.s.o. an rpm install.

Other than that, it's basically the same system I've used for years. 2 
daemons in the system that do other stuff keep working just fine, they 
open a db connection when they start, and do small queries every 5 to 
10 seconds. They don't loose the connection.

Anyone any ideas?

Thanks,

Bas.



Re: MySQL server has gone away?

Posted by Bas Schulte <bs...@zeelandnet.nl>.
Hi Harm,

On zondag, apr 10, 2005, at 10:53 Europe/Amsterdam, harm wrote:

>> 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.
>
> 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'll try that. Maybe the timeout settings are different for this MySQL 
instance, don't know.

But it's still werid, basically the same setup has been running just 
fine for many years.


>> 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.

I suspect this might have something to do with the problem, as it's the 
biggest change in the code; doing stuff during BEGIN.

I do get a message from Apache::DBI during startup, on stderr:

10039 Apache::DBI             skipping connection during server 
startup, read the docu !!

I'll investigate further, thanks for the info.

Regards,

Bas.


Re: MySQL server has gone away?

Posted by harm <ha...@millionmonkeys.nl>.
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)