FAQ
Hello,

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?


Thanks.

Search Discussions

  • Dr.Ruud at Dec 12, 2009 at 5:34 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedDec 12, '09 at 8:02a
activeDec 12, '09 at 5:34p
posts2
users2
websiteperl.org

2 users in discussion

Ryan Chan: 1 post Dr.Ruud: 1 post

People

Translate

site design / logo © 2022 Grokbase