From:             danielc at analysisandsolutions dot com
Operating system: Windows XP SP3
PHP version:      5.3CVS-2009-03-12 (snap)
PHP Bug Type:     MySQLi related
Bug description:  mysqli connect timeout causes fatal error

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 bug report at http://bugs.php.net/?id=47629&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47629&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47629&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47629&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47629&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47629&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47629&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47629&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47629&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47629&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47629&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47629&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47629&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47629&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47629&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47629&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47629&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47629&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47629&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47629&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47629&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47629&r=mysqlcfg

Reply via email to