First, I would like to thank etully for the kind words and the suggestion to check my mysql logs.
To answer bradgrafelman yes, login.php does open a mysql_connect() and queries mysql to authenticate the login credentials and grab some info about the user loging in. And this is the start of the problem.
After some testing I concluded that mysqld dies every time a php script which queries my mysql DB ends. Mysqld dying s independent of sessions, output_buffering, mysql_close() statements or how I call mysql_connect() . This does not happen when I use the mysql commend shell.
I am noticing the mysqld deaths because second_page.php is trying to open a mysql connection before mysqld has time to complete restarting.
I spent to many hours trying to fix this but to no avail. Note: the text below deals more with mysql and Linux than PHP.
Mysqld.log contains this for each page load that has a mysql_connect()
070330 10:26:48 mysqld restarted
/usr/libexec/mysqld: ready for connections
libgcc_s.so.1 must be installed for pthread_cancel to work
Number of processes running now: 0
070330 10:26:48 mysqld restarted
/usr/libexec/mysqld: ready for connections
Things checked or done to fix it.
libgcc_s.so.1 is installed and mysqld knows where it is
ldd /usr/libexec/mysqld
libdl.so.2 => /lib/libdl.so.2 (0x40027000)
[SNIP]
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40160000)
[SNIP]
ls -laF /lib/libgcc_s
-rwxr-xr-x 1 root root 30324 Feb 25 2003 /lib/libgcc_s-3.2.2-20030225.so.1
lrwxrwxrwx 1 root root 28 Mar 30 09:40 /lib/libgcc_s.so.1 -> libgcc_s-3.2.2-20030225.so.1*
Things that did not prevent mysql from dying:
Reinstalling libgcc-3.2.2-5.i386.rpm (no newer version available)
Rebooting
Adding 'LoadFile /lib/libgcc_s.so.1' to httpd.conf
Restarting mysqld
Restarting htppd
Adding a 0.100 second delay gave mysqld enough time to restart. I went ahead and doubled it to 0.20 seconds since the delay is probably less annoying than the occasional mysql_connect errors
So in my login.php i have
usleep(200000);
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/second_page.php");
This is not a fix, but a clunky work around. This server is old, and I plan to replace it this summer, so I'll live with my 0.20 s. of sleep for now unless soemone has a solution.
Thanks again,
Don