|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28098 mysql_pconnect never kills threads
Submitted: 2004-04-21 19:17 UTC Modified: 2004-04-22 18:26 UTC
From: moreau at myrealbox dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.6 OS: FreeBSD 5.2.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
31 - 17 = ?
Subscribe to this entry?

 [2004-04-21 19:17 UTC] moreau at myrealbox dot com
mysql_pconnect every time generate new connection and never kill previous.
As result - MySQL generate many threads for handling each query and after too many connection hangs.
This never happened if use mysql_connect and mysql_close in each page.

I use apache2 . php compiled as module. apache use mpm=worker. I don't know whether it problem in threadead apache or common problem in php with mysql_pconnect.

mysql_pconnect in current state cannot be used for accessing to mysql.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-21 19:19 UTC]
mysql extension will create one connection per database 
connect string per PHP interpreter context, i.e. one per 
Apache thread or child.  Is the number of connections 
you are seeing exceeding your Apache thread count?

 [2004-04-21 22:02 UTC] moreau at myrealbox dot com
Yes, significantly.
Each script is successfully ended , so apache returns in 
normal state ( minimal threads and process - as pointed in config ) after long timeout ( when pages aren't requested ). But MySQL has many threads and no one of threads never die.
 [2004-04-22 01:54 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Persistent connections remain active until the Apache is 
shutdown. This is expected behavior. 
 [2004-04-22 08:36 UTC] moreau at myrealbox dot com
Thanks for your answer too, I didn't know that persistent connection is not closed after ending script.
But I don't agree that such behaviour as I describe is normal. As I mentioned pconnect generate new thread in each new running script.
BUT THIS IS THE SAME SCRIPT! So as said in documentation 
pconnect should REUSE old connection , BUT DON'T generate
new connection. In practice - pconnet don't close any connection at all, but don't reuse previous connection and
generate new.
Is this also correct behaviour ?
 [2004-04-22 18:26 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

When using threads you should not be using persistent 
connections, because PHP cannot identify existing 
connections as already avaliable and therefor opens a new 
persistent connection each time. 
 [2011-07-07 17:28 UTC] jose dot nobile at gmail dot com
I don't found any form to use persistent connections.

No threads, no working
threads, no working
php in console, no working

What is the enviroment to use persistent connections?

Apache + forker
Apache + Worker
Apache + PHP fastcgi


This is not a bogus, is a real BUG of 7 years old.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Oct 01 11:01:24 2023 UTC