Hi all I am encountering a problem with DBD::mysql 4.20.0-r1, perl 5.20 and mysql 5.5 on amd64 Linux.
The driver does not reconnect to the db once the server has closed the session (eg. after trying to send data that exceeds max_allowed_packet). The code (a persistant daemon application) connects to mysql at startup like this: my $dbh = DBI->connect($dsn, $username, $passwd, { RaiseError => 1, AutoCommit => 1, AutoInactiveDestroy => 1, mysql_auto_reconnect => 1, mysql_enable_utf8 => 1, mysql_connect_timeout => 5, } ); The $dbh handle is then shared between multiple objects in the same process. Each object prepares some statements of its own via $dbh->prepare(...) at creation time (startup). The code within each object class then follows this basic structure: sub do_something { [...] my $rv; $dbh->begin_work(); eval { # $sth was prepared at creation time $rv = $sth->execute(...); # fails if max_allowed_packet is exceeded $rv = 0 unless(defined $rv && $rv ne '0E0'); [...] $dbh->commit(); }; if($@ or not $rv) { [...] $dbh->rollback(); } [...] } Now when the mysql server closes the connection because of an error during $sth->execute(), there are two consecutive errors: First. the execute fails with: DBD::mysql::st execute failed: MySQL server has gone away at ... And then, the rollback also fails: DBD::mysql::db rollback failed: MySQL server has gone away at ... And after that, all subsequent attempts to use the handle immediately fail with "MySQL server has gone away", in all objects that use the handle. For some reason, the driver does not try to reconnect (tcpdump shows that no packets are sent to the server). >From the docs I got the impression that it should reconnect if AutoCommit is 1. AutoCommit is set to 0 by begin_work() and should be set back to 1 by rollback() or commit(), as far as I understood. But now rollback() seems to fail, and the driver never reconnects, so could it be that AutoCommit never gets set back to 1? Trying to set it manually after the first two errors results in DBD driver has not implemented the AutoCommit attribute at ... Am I doing something totally wrong here, or have I misunderstood the documentation? Thx for any pointers Markus