|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-04-02 16:47 UTC] rgagnon24 at gmail dot com
[2013-04-02 16:48 UTC] rgagnon24 at gmail dot com
[2013-06-07 10:00 UTC] uw@php.net
[2013-06-14 05:09 UTC] rgagnon24 at gmail dot com
[2014-10-30 13:39 UTC] patryk dot kozlowski at toxic-software dot pl
[2017-02-08 09:01 UTC] steffen dot weber at gmail dot com
[2017-02-08 09:03 UTC] steffen dot weber at gmail dot com
[2018-10-15 20:45 UTC] nick at sabramedia dot com
[2020-04-17 12:41 UTC] cmb@php.net
[2021-06-09 13:43 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Package: MySQL related
+Package: PDO MySQL
-Assigned To:
+Assigned To: cmb
[2021-06-09 13:43 UTC] cmb@php.net
[2021-06-20 04:22 UTC] php-bugs at lists dot php dot net
[2021-06-20 06:04 UTC] rgagnon24 at gmail dot com
-Status: No Feedback
+Status: Closed
[2021-06-20 06:04 UTC] rgagnon24 at gmail dot com
[2021-06-20 06:05 UTC] rgagnon24 at gmail dot com
-Status: Closed
+Status: Open
[2021-06-20 06:05 UTC] rgagnon24 at gmail dot com
[2021-06-20 06:06 UTC] rgagnon24 at gmail dot com
[2021-06-20 06:07 UTC] rgagnon24 at gmail dot com
-Summary: mysqlnd persistent connection handling out of control
+Summary: mysqlnd persistent connection handling are not
properly pooling
[2021-06-20 06:07 UTC] rgagnon24 at gmail dot com
[2021-06-20 08:30 UTC] wf3f2g dot wf2f3f at egrg dot dd
[2021-06-21 09:34 UTC] cmb@php.net
[2021-06-21 09:34 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Assigned To: cmb
+Assigned To:
[2021-06-21 13:29 UTC] rgagnon24 at gmail dot com
[2024-05-22 05:25 UTC] sonia0992alvarez at outlook dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 03:00:01 2025 UTC |
Description: ------------ When PHP 5.3 is compiled with --enable-mysqlnd=shared --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd In order to use the native driver, persistent connections using PDO don't appear to use any kind of managable or determinate connection pooling. Running the test script below via apache web server, refreshing the page every few seconds (10 or 12 times), will produce at least 10 connections to the database as shown by the mysql "SHOW PROCESSLIST" command... yet the phpinfo() section will indicate a number that is not the same as the actual number of connections. In my test prior to posting, I had 10 actual connections (of which 9 were sleeping, and the 10th one was just used to run the test query) and phpinfo() showed 5 active_persistent_connections, and pconnect_success was 8 (under the mysqlnd stats section). This leads me to believe there may be a memory leak in the area of code where the module is managing the connection pool. If no memory leak, the management of the connections is off somehow as idle connections to a production webserver are ridiculously high. Test script: --------------- <?php $options = array( PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, ); $host_name = 'database_host'; $database_name = 'some_database'; $port = 3306; $username = 'db_user'; $password = 'db_pass'; $dsn = sprintf("mysql:host=%s;dbname=%s;port=%d", $host_name, $database_name, $port); $dbh = new PDO($dsn, $username, $password, $options); $sql = 'SELECT * FROM test WHERE id=1 LIMIT 1'; print "<pre>"; $stmt = $dbh->query($sql, PDO::FETCH_ASSOC); while ($row = $stmt->fetch()) { var_dump($row); } $stmt->closeCursor(); print '</pre>'; Expected result: ---------------- active_persistent_connections and pconnect_success should be accurate to match what you are really doing. Also the command line 'netstat -anp|grep :3306|grep httpd|grep ESTABLISHED" should show a limit at some point on the number of connections that are persistent, or they should get re-used. Actual result: -------------- There are a lot of unaccounted for idle ESTABLISHED in the netstat command, for connections from httpd to mysql when mysqlnd indicates there are not that many.