ID: 29074 Comment by: phpbugreport at workboy dot com Reported By: david dot blair at nsi1 dot com Status: Open Bug Type: MSSQL related Operating System: MS 2003 PHP Version: 4.3.7 New Comment:
If you have access to a packet sniffer and the basic knowhow, I would recommend sniffing the connection to and from port 1433 of your MSSQL server (if you are using 1433 that is) and the web server having the connect problems. I was able to determine that this problem was on the SQL side of things by looking at the packet trace. I would log mssql_connect failures that were corrected by a second attempt and matched their times exactly to TCP RESET packets being sent from the MSSQL server back to the web server requesting a connection to port 1433. This allowed me to rule out PHP as the source of the failure. As to why newer versions of PHP cause this more than older versions, all I can assume is that the newer PHP is more efficient in some way in opening TCP connections and this is causing greater concurrency in TCP connection requests to the SQL server. With a listen backlog of 25 on my SQL server I still see occasional failures but that is within an acceptable range now as they are handled by trying again immediately. If the number starts to go up, I will try increasing my listen backlog. I also observed that an entirely separate problem on my SQL server related to the RAID card increased the failure rate so there appear to be other mitigating factors on the SQL end. Fixing the RAID issue make the connect failures rate drop down to zero again. Charles Previous Comments: ------------------------------------------------------------------------ [2004-09-29 20:29:38] david dot blair at nsi1 dot com (In response to two posts ago) Charles, I tried your fix by setting the winsocklistenbacklog to 16. Didn't work. Had three more incidents today where the first connection was refused but on an instant reconnect it worked. ------------------------------------------------------------------------ [2004-09-22 07:37:08] pretenda at pretenda dot com I am also having the same problem. I have been searching high and low for an answer, but have found none. I ended up creating a loop in my PHP connect code too, and it has attempted to connect more than once, 27 times on my development server in the past week. I am running the following: Windows 2003 Server IIS6 PHP 5.01 SQL Server 2000 SP3 A also previously had the issue on 4.3.8, which didn't fail as often. Unfortunately I need some of the features of PHP5 on my new website. Cheers, Matt ------------------------------------------------------------------------ [2004-09-21 23:57:14] david dot blair at nsi1 dot com Charles, this doesn't explain why newer versions of PHP cause the error more frequently than older versions, when everything else about our systems remains the same. This also doesn't explain why PHP is the only thing having issues that contacts my SQL server. I'll try your work-around tomorrow and monitor the server for a few weeks to see what happens. It's a step in the right direction to finding a solution if it does help, but I still see it as a work-around, not a solution. ------------------------------------------------------------------------ [2004-09-21 23:36:13] phpbugreport at workboy dot com This bug should probably be closed. The problem is on the MSSQL end and ban be resolved by changing the value of the winsocklistenbacklog registry entry. For those who are experiencing this problem, please see http://support.microsoft.com/default.aspx?kbid=328476 I don't know why this also affects mssql_select_db, but they do appear to go together. ------------------------------------------------------------------------ [2004-09-13 00:42:39] phpbugreport at workboy dot com Upgrading seems to make things worse. I upgraded to freetds-0.62.4, php-4.3.9RC2 (4.3.8 has a compile issue with freetds-0.62.4 according to bug reports), and apache 1.3.31. Now in addition to mssql_connect failures I also get mssql_select_db failures for one of our busier databases. Could it be that php/freetds is getting too fast and giving up before a response is received from SQL 2000? Charles Bennigton Oddcast, Inc. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/29074 -- Edit this bug report at http://bugs.php.net/?id=29074&edit=1