#36602 [NEW]: "MySQL server has gone away" with PDO::ATTR_PERSISTENT => true

From: Date: Fri, 03 Mar 2006 10:26:09 +0000
Subject: #36602 [NEW]: "MySQL server has gone away" with PDO::ATTR_PERSISTENT => true
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93876@lists.php.net to get a copy of this message
From: nerve at gmx dot net Operating system: Gentoo Linux PHP version: 5.1.2 PHP Bug Type: PDO related Bug description: "MySQL server has gone away" with PDO::ATTR_PERSISTENT => true Description: ------------ My Site connect with PDO and PDO::ATTR_PERSISTENT => true to MySQL. If the MySQL server is restarting or a tread of the Server is killed, the Apache tread wich is connected cant execute any statements until Apache was restartet. The PDO Connect return with succes, but the first query fails with "MySQL server has gone away". A MySQL Server restart was no problem with the old mysql_pconnect function. I want a detection on creation of new PDO object with persistent connection if the connection is alive or a method to close the old connection. I use php 5.1.2 with apache 2.0.55 on gentoo linux with mysql 5.0.18-log Please se my workaround code, witch make a fallback to slower non persistent object. Reproduce code: --------------- // Workaround code for problem with pdo and persistent connection try { $db = new PDO('mysql:host='.$db_host.';dbname='.$db_db, $db_user,$db_pw, array(PDO::ATTR_PERSISTENT => true)); $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $db_info = $db->getAttribute(PDO::ATTR_SERVER_INFO); // erkennung von toten persistenten verbindungen ... if($db_info == "MySQL server has gone away") { $db = null; $db = new PDO('mysql:host='.$db_host.';dbname='.$db_db, $db_user,$db_pw); } }catch (PDOException $e) { print "Fehler in der DB Verbindung!: " . $e->getMessage() . "<br/>"; $db = null; die(); } Expected result: ---------------- alive persistent connection if mysql is running ! Actual result: -------------- dead mysql persistent connection if mysql was restartet !!! -- Edit bug report at http://bugs.php.net/?id=36602&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36602&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36602&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36602&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36602&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36602&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36602&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36602&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36602&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36602&r=support Expected behavior: http://bugs.php.net/fix.php?id=36602&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36602&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36602&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36602&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36602&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36602&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36602&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36602&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36602&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36602&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36602&r=mysqlcfg

« previous php.bugs (#93876) next »