#47629 [Fbk]: mysqli connect timeout causes fatal error
| From: | pajoye@php.net | Date: | Sat, 20 Jun 2009 20:12:24 +0000 |
| Subject: | #47629 [Fbk]: mysqli connect timeout causes fatal error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-138562@lists.php.net to get a copy of this message | ||
ID: 47629
Updated by: pajoye@php.net
Reported By: danielc at analysisandsolutions dot com
Status: Feedback
Bug Type: MySQLi related
Operating System: Windows XP SP3
PHP Version: 5.3CVS-2009-03-12 (snap)
Assigned To: pajoye
New Comment:
but there is no bug here. Why do you want to let the socket timeout
override the main timeout?
Previous Comments:
------------------------------------------------------------------------
[2009-06-20 17:34:32] danielc@php.net
Yes, the execution timeout makes sense some ways. The problem is the
behavior is inconsistent between 5.2 and 5.3 and between other
connection functions.
------------------------------------------------------------------------
[2009-06-20 13:19:04] pajoye@php.net
With:
max_execution_time: 2
default_socket_timeout: 6
It is the expected behavior to have a fatal error about the maximum
execution time being exceeded. max_execution_time has the highest
importance.
------------------------------------------------------------------------
[2009-03-12 04:41:21] danielc at analysisandsolutions dot com
Description:
------------
A fatal error is generated if a MySQLi connection attempt times out AND
the default_socket_timeout ini setting is greater that the
max_execution_time ini setting. This is happening in PHP 5.3, Mar 11
2009 17:04:24, VC6 thread safe snapshot build.
This does not happen on timeouts when using socket_bind().
This does not happen in PHP 5.2.9-1.
Reproduce code:
---------------
// BOGUS MYSQL PORT NUMBER IS INTENTIONAL.
echo 'PHP ' . phpversion() . "\n\n";
echo "ONE ---------------\n";
ini_set('max_execution_time', 6);
ini_set('default_socket_timeout', 2);
echo 'max_execution_time: ' . ini_get('max_execution_time') . "\n";
echo 'default_socket_timeout: ' . ini_get('default_socket_timeout') .
"\n";
$mysqli = new mysqli('localhost', 'does', 'not', 'matter',
1);
if ($mysqli->connect_error) {
echo "GOOD CATCH\n\n";
}
echo "TWO ---------------\n";
ini_set('max_execution_time', 2);
ini_set('default_socket_timeout', 6);
echo 'max_execution_time: ' . ini_get('max_execution_time') . "\n";
echo 'default_socket_timeout: ' . ini_get('default_socket_timeout') .
"\n";
$mysqli = new mysqli('localhost', 'does', 'not', 'matter',
1);
if ($mysqli->connect_error) {
echo "GOOD CATCH\n\n";
}
Expected result:
----------------
PHP 5.3.0beta2-dev
ONE ---------------
max_execution_time: 6
default_socket_timeout: 2
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt
failed because the connected party did not (trying to connect via
tcp://localhost:1) in ...
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in ...
GOOD CATCH
TWO ---------------
max_execution_time: 2
default_socket_timeout: 6
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt
failed because the connected party did not (trying to connect via
tcp://localhost:1) in ...
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in ...
GOOD CATCH
Actual result:
--------------
PHP 5.3.0beta2-dev
ONE ---------------
max_execution_time: 6
default_socket_timeout: 2
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt
failed because the connected party did not (trying to connect via
tcp://localhost:1) in ...
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in ...
GOOD CATCH
TWO ---------------
max_execution_time: 2
default_socket_timeout: 6
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt
failed because the connected party did not (trying to connect via
tcp://localhost:1) in ...
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in ...
Fatal error: Maximum execution time of 2 seconds exceeded in ...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47629&edit=1