Visite Webhosting Latino, el site sobre alojamiento web.
true, mombu forums" /> true Php" /> #36602 : "MySQL server has gone away" with PDO::ATTR_PERSISTENT => true - Mombu the Php Forum
Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #36602 : "MySQL server has gone away" with PDO::ATTR_PERSISTENT => true
User Name
REGISTER NOW! Mark Forums Read

sponsored links

1 11th August 06:24
External User
Posts: 1
Default #36602 : "MySQL server has gone away" with PDO::ATTR_PERSISTENT => true

ID: 36602
Updated by:
Reported By: nerve at gmx dot net
Status: Open
Bug Type: PDO related
Operating System: Gentoo Linux
PHP Version: 5.1.2
New Comment:

Libmysql client library doesn't allow reconnect by default since
version 5.0.3 (Also mysql_pconnect shouldn't work after restarting
MySQL server).

Previous Comments:

[2006-03-03 11:26:07] nerve at gmx dot net

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

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

I use php 5.1.2 with apache 2.0.55 on gentoo linux with mysql

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_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,
}catch (PDOException $e)
print "Fehler in der DB Verbindung!: " . $e->getMessage() .
$db = null;

Expected result:
alive persistent connection if mysql is running !

Actual result:
dead mysql persistent connection if mysql was restartet !!!


Edit this bug report at
  Reply With Quote

  sponsored links


Thread Tools
Display Modes

Copyright 2006 - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -