ID:               19541
 Comment by:       roger dot flink at easit dot se
 Reported By:      mlaukast1 at hotmail dot com
 Status:           No Feedback
 Bug Type:         MSSQL related
 Operating System: Windows NT4(SP6)
 PHP Version:      4.2.3
 New Comment:

I have the same problem mentioned above... :(


Previous Comments:
------------------------------------------------------------------------

[2002-12-23 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over 2 weeks, 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".

------------------------------------------------------------------------

[2002-12-07 01:38:08] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip



------------------------------------------------------------------------

[2002-09-23 17:22:22] mlaukast1 at hotmail dot com

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.

------------------------------------------------------------------------

[2002-09-21 10:40:49] mlaukast1 at hotmail dot com

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

Reply via email to