|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-02 11:41 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2021-07-02 11:41 UTC] cmb@php.net
[2021-07-11 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 15:00:01 2025 UTC |
Description: ------------ at some random calls i can't connect to mysql and no error is report back. this issue is present with nginx + php-fpm + mysql with multiple sites running on the same server. After digging, i found that this error is cause by a odbc call from one of the sites. when the odbc call is done one some php-fpm child and other site tries to connect using mysqli_connect on this same php-fpm child it simple fails and no error is thrown. the return link is false. if its relevant, the odbc connection is configure over unixodbc directly to /var/run/mysqld/mysqld.sock. i could reproduce the error using simple php script with cli, attached the script to reproduce it. I've try to connect to 127.0.0.1 instead of the socket, but i got the same results. Test script: --------------- <?php // when connecting to odbc will make fail all the mysql connections using_odbc(); sleep(5); using_mysqli_obj(); using_mysqli(); function using_mysqli() { echo "*** MySQLi \n"; $link = mysqli_connect("localhost", "root", "m1sq7passwd", "tel_app", "3306", "/var/run/mysqld/mysqld.sock"); if (!$link) { echo "Error connecting to MYSQL [".mysqli_connect_errno()."] ".mysqli_connect_error()."\n"; } else { $result = @mysqli_query($link, "select count(*) as total from client_limit;"); if (!is_object($result)) { echo "no results found, error: ".mysqli_error($link)."\n"; } else { $tmp = mysqli_fetch_array($result, MYSQLI_ASSOC); mysqli_free_result($result); print_r($tmp); } if (!mysqli_close($link)) { echo "Fail to disconnect db link \n"; } unset($link); } echo "***\n"; } function using_mysqli_obj() { echo "*** MySQLi OBJ\n"; $mysqli = new mysqli('localhost', 'root', 'm1sq7passwd', 'tel_app'); if ($mysqli->connect_error) { echo ('Connect Error (' . $mysqli->connect_errno . ') '.$mysqli->connect_error); } else { $result = $mysqli->query("select count(*) as total from client_limit;", MYSQLI_USE_RESULT); if (!is_object($result)) { echo "no results found, error: ".$mysqli->error."\n"; } else { $tmp = $result->fetch_object(); print_r($tmp); $result->close(); } $mysqli->close(); } echo "*** \n "; } function using_odbc() { echo "*** ODBC \n"; $conn = odbc_connect("localhost_tel_cdr", false, false); if (!$conn) { echo "fail to connect using odbc ".odbc_errormsg(); } else { $res = odbc_exec($conn, "select count(*) as total_cdr from cdr where (start_stamp >= '1470751734' ) and (start_stamp <= '1471356534' );"); if (!$res) { echo "Fail to execute sql ".odbc_errormsg(); } else { $row = odbc_fetch_array($res); print_r($row); odbc_free_result($res); } odbc_close($conn); } echo "***"; } ?> Expected result: ---------------- *** ODBC Array ( [total_cdr] => 98 ) *** MySQLi OBJ stdClass Object ( [total] => 216 ) *** *** MySQLi Array ( [total] => 216 ) *** Actual result: -------------- *** ODBC Array ( [total_cdr] => 98 ) ****** MySQLi OBJ Warning: mysqli::query(): Couldn't fetch mysqli in /root/mysql_phpbug.php on line 47 Warning: using_mysqli_obj(): Couldn't fetch mysqli in /root/mysql_phpbug.php on line 49 no results found, error: Warning: mysqli::close(): Couldn't fetch mysqli in /root/mysql_phpbug.php on line 56 *** *** MySQLi Error connecting to MYSQL [0] ***