ID: 19541 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: MSSQL related Operating System: Windows NT4(SP6) PHP Version: 4.2.3 New Comment:
I switched to CGI and I can confirm that the error doesn't occur anymore. However, as I expected I've run into some serious performance problems under heavy load (CPU usage extremely high, script execution timeouts etc.). Therefore I'd really like to see this working under ISAPI as well. Does this error suggest that the mssql extension has problems with thread safety? My opinion is that if ISAPI was stable and working well, it would be a major break-through for the PHP in Windows platforms. I honestly hope PHP group is taking Windows platforms seriously and putting effort to them. Previous Comments: ------------------------------------------------------------------------ [2002-09-21 10:40:49] [EMAIL PROTECTED] I have found out that mssql_connect fails under stress. I'm using PHP 4.2.3/ISAPI on IIS4/NT4(SP6). MSSQL 7.0 Server is a dedicated dual processor server with NT4(SP6). I've installed MDAC 2.7 RTM on the web server and performance setting is set to foreground applications (read bug: 9852). I've despertately searched solution to this problem, since the site I'm running is on production state already. I experienced this bug with PHP 4.2.2 at first then moved on to 4.2.3 without any change to the problem. The error occurs on a line: $dbconn = mssql_connect($dbalias,$dbuser,$dbpw); and application log entry for the error is: The description for Event ID ( 2000 ) in Source ( c-client ) could not be found. It contains the following insertion string(s): , PHP Warning: MS SQL: Unable to connect to server: *dbname* in *path* on line x. I'm using TCP/IP protocol, however I've tried named pipes and multiprotocol without help. I've tried to work around this problem and I found out that usually this error occurs when several users are trying to connect to the database simultaneously. I managed to reduce the appearance of the error with the code: function usleepWindows($usec) { $start = gettimeofday(); do { $stop = gettimeofday(); $timePassed = 1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec']; } while ($timePassed < $usec); } $tries=11; $totaldelay=0; // Set db connection $dbconn = mssql_connect($dbalias,$dbuser,$dbpw); while(!$dbconn){ if ($tries<=0){ echo "Database failed to respond."; $fp = fopen("c:\\logs\\conn_failed.log","a"); fputs($fp, gmdate("M d Y H:i:s") . ": db connection failed. Total delay: $totaldelay. From: $REMOTE_HOST.\r\n"); fclose($fp); exit; } $delay=mt_rand(80000, 150000); usleepWindows($delay); $conn = mssql_connect($dbalias,$dbuser,$dbpw); $tries--; $totaldelay += $delay; } The function usleepWindows was found from http://www.php.net/manual/en/function.usleep.php. I haven't tried the CGI yet and wouldn't want to since it will surely suffocate the web server under load. ISAPI is far more superior and my other experiences of it are very positive. I hope to find a solid answer to this problem as it very critical to my site. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19541&edit=1