php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44555 mysql.connect_timeout ignored
Submitted: 2008-03-28 09:03 UTC Modified: 2009-10-15 16:01 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:1 (14.3%)
Same OS:3 (42.9%)
From: tstarling at wikimedia dot org Assigned: uw (profile)
Status: Not a bug Package: MySQL related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tstarling at wikimedia dot org
New email:
PHP Version: OS:

 

 [2008-03-28 09:03 UTC] tstarling at wikimedia dot org
Description:
------------
mysql.connect_timeout is ignored, a fixed timeout of 20s is used. Observed on PHP 5.2.5 WinXP, not observed on PHP 5.1.4 Linux.

Reproduce code:
---------------
print mysql_get_client_info() ."\n";
ini_set('mysql.connect_timeout',1);
$t = -microtime(true);
mysql_connect('1.2.3.4');
$t += microtime(true);
print "$t\n";
ini_set('mysql.connect_timeout',100);
$t = -microtime(true);
mysql_connect('1.2.3.4');
$t += microtime(true);
print "$t\n";


Expected result:
----------------
5.0.45
1.00128006935
99.9788169861

Actual result:
--------------
5.0.45
20.9900009632
21.0206007957


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-14 16:57 UTC] uw@php.net
Does the host 1.2.3.4 exist? If not, you're probably running into the default DNS lookup timeout of your system -> bogus, not a bug. Try changing your system settings, http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/96406.mspx?mfr=true
 [2008-07-15 15:27 UTC] tstarling at wikimedia dot org
No of course the host "1.2.3.4" doesn't exist, it's an IP address in the unused 1.0.0.0/8 block reserved by ARIN, that's the point. 

If I instead use a hostname for a host which responds to DNS rapidly, but drops ignores SYN packets on the port in question (such as www.google.com), the result is the same. 

Are you asking me this question because you've tried it and can't reproduce it? If so, maybe I can help to isolate the configuration.
 [2008-07-15 16:21 UTC] tstarling at wikimedia dot org
s/ARIN/IANA
 [2008-07-16 22:36 UTC] uw@php.net
As I see it the upper wait time is set to 100s. Your Windows gives a DNS timeout after 20s. PHP bails at you after 20s. 20s < 100s, all fine.


 [2008-07-17 09:44 UTC] tstarling at wikimedia dot org
I don't know what you're talking about. The bug is not DNS-related.
 [2008-07-23 12:12 UTC] andrey@php.net
Hi,
\I suspect a problem in libmysql, not PHP.
The ext/mysql sources do set the connect_timeout

if (connect_timeout != -1) {
  mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
}

Are you sure you don't have several libmysql.dll on your system?
 [2008-07-31 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-10-15 16:01 UTC] uw@php.net
Windows, libmysql, connect timeout -> libmysql/MySQL bug not a PHP issue -> http://bugs.mysql.com/bug.php?id=36225
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC