Ryan Chan wrote:

Sometimes, my sql is running for a quite long time, e.g. 1 hour

The perl script will warn "DBD::mysql::st execute failed: MySQL server
has gone away at ..." and my script failed.

I have already set the auto reconnect, e.g.

 $dbh->{mysql_auto_reconnect} = 1;

But problem still occur, any idea?

MySQL auto-reconnect is evil, because not all attributes of the connection are restored.

What you are looking for is probably

  $dbh->do("SET SESSION wait_timeout=36000");

but that my still not be what you *really* need.

With MySQL, it is always best to connect only just before the query starts, and disconnect after. Use a block for that, or a "do {}".

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to