php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #90 mysql_pconnect isn't reusing connections
Submitted: 1998-02-20 05:28 UTC Modified: 1998-02-20 06:42 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: Brian dot Craigie at necs dot demon dot co dot uk Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0 Latest CVS OS: Solaris 2.5
Private report: No CVE-ID: None
 [1998-02-20 05:28 UTC] Brian dot Craigie at necs dot demon dot co dot uk
(as previously posted to the PHP3 list)

Evidence shows that repeated identical mysql_pconnect (or mysql_connect) statements aren't reusing the link connections.

Executing a php3 script with one mysql_pconnect(host,user,passwd) type of statement generates 2 lines in netstat | grep 3306 (one for each direction host-client).
Hitting reload in the browser generates a further 2 lines in netstat | grep 3306 each time.

The connections disappear after about 30 minutes.

Each connection presumably takes up memory and this may well be the reason for running out of memory in bug id 79.

Issuing mysql_close doesn't make any difference with mysql_connect.

Cheers!

Brian

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-02-20 06:42 UTC] zeev
Please read the FAQ regarding persistent connections.  The bottom line is
that persistent connections are working perfectly well, but there'll
usually be way more than just one persistent connection.  There'll usually
be one persistent connection for each httpd process alive, which can be any
number, usually around 5-50, can be less or more depending on how busy your
site is.

Did you mean with mysql_pconnect() or was mysql_connect() intentional?
Persistent links can NOT be closed in any way other than shutting down the
web server.  mysql_close() on a persistent link will only close the link
for the duration of the script, but not close the actual link to the server
(that is, a future pconnect in the same script or a different script will
be able to reuse that link).

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 15:01:25 2019 UTC