Jump to content

PHP Fork: Too Many Connections


jkds

Recommended Posts

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.