php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17581 mysql_connect hangs Apache
Submitted: 2002-06-03 13:52 UTC Modified: 2002-06-12 15:39 UTC
From: hermannj at slu dot edu Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.1.2 OS: Tru64 Unix
Private report: No CVE-ID: None
 [2002-06-03 13:52 UTC] hermannj at slu dot edu
Apache child processes hang when:
1. A PHP script (let's call it connect.php) sends a mysql_connect request to a MySQL server.
2. The MySQL server is powered down - completely shut off.

Example of connect.php:
<?php mysql_connect("db","user","pass") || or die("OMG!"); ?>

ps ax | grep httpd | wc shows 14 httpd processes

After calling http://www.domain.com/connect.php with a browser
ps ax | grep httpd | wc shows 15 httpd processes
Hitting stop on the browser has no affect. 15 processes remain.

After calling /apache/bin/ap -n 200 -c 200 http://www.domain.com/connect.php
This will call the script 200 times concurrently.
ps ax | grep httpd | wc shows 152 httpd processes (MaxClients reached)

Now going to http://www.domain.com/ produces nothing but a timeout.
Since there is no mysql_connect timeout, the Apache processe hang indefinately.
Result: server hosed!  This is much too fragile.
Gracefuly restarting Apache has no affect since it is waiting for the child processes to complete.  You must stop Apache and start Apache to resume operations.

Environment:
Tru64 Unix
PHP 4.1.2
MySQL builtin libraries


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-03 14:03 UTC] mfischer@php.net
Does this also occure if you use external libraries?

Can you also try to upgrade to 4.2.1, enable with debug (also on apache if possible), and use the strace utility on httpd -X to track down where it actually hangs?

Btw, which apache version?
 [2002-06-12 15:23 UTC] hermannj at slu dot edu
I upgraded as suggested.  Current set up:
Apache 1.3.24
PHP 4.2.1
OpenSSL 0.9.6d
mod_ssl 2.8.8-1.3.24
etc...

However, MySQL has never compiled without errors for me on Tru64 4.0 despite having used the Tru64 install suggestions on MySQL.com.

MySQL builtin

I ran the same test as described earlier.  This time Apache child processes did not hang.  I pushed it to a worse  scenario having the connect.php script loop the connection attempt 30 times.  The total would then become 200x30=6000 attempts.  Apache complained but finished the requests and then began terminating child processes normally.

Excellent!  We'll be moving this to production as soon as we make changes to our PHP code due to new behaviors in PHP 4.2.1. If any problems crop up, I'll submit a report.  

Thanks for your help.
 [2002-06-12 15:39 UTC] sniper@php.net
Closing this then. You should propably inform the Mysql people about those compile problems. Try zak@mysql.com as
he's the one maintaining the bundled mysql libs too.

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 11:00:02 2026 UTC