jkds Posted November 20, 2009 Share Posted November 20, 2009 Hi all, I'm forking PHP, and creating a new MySQL connection with each child process using mysql_connect (NOT pconnect). This new connection creation method is necessary to get round the "MySQL server has gone away" issue commonly found with PHP forks. Thing is, the connections aren't closing, eventually resulting in a "Too many connections" error. The "show processlist" command displays lots of connections with the command showing as "Sleep". Each child process ends with the following code: //close the connection mysql_close($childconns[$connid]); //end child posix_kill(getmypid(),9); exit(); ..but to no avail - the connection remains open. I've reduced the wait_timeout variable in MySQL to 300, which solves the problem. BUT some of these child processes may take a long time (like, 20 minutes plus... they're FTP uploads), and so will lose their database connection (I assume). So my question is: can anyone help me kill my PHP children?! Thanks! PS. Apologies if this is posted in the wrong place - bit of a cross-forum issue... Quote Link to comment https://forums.phpfreaks.com/topic/182281-php-fork-too-many-connections/ Share on other sites More sharing options...
Mchl Posted November 20, 2009 Share Posted November 20, 2009 [snip] Duh... should've read more carfully. [added] Perhaps try closing connection from within child processes? Quote Link to comment https://forums.phpfreaks.com/topic/182281-php-fork-too-many-connections/#findComment-961855 Share on other sites More sharing options...
jkds Posted November 24, 2009 Author Share Posted November 24, 2009 I'm up to my ankles in zombies here... anyone? Quote Link to comment https://forums.phpfreaks.com/topic/182281-php-fork-too-many-connections/#findComment-964803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.