php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12084 pg_close cause a lot of sockets in TIME_WAIT state
Submitted: 2001-07-12 02:42 UTC Modified: 2001-07-13 08:12 UTC
From: gianpaolo at preciso dot net Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.0.6 OS: Debian 2.2
Private report: No CVE-ID: None
 [2001-07-12 02:42 UTC] gianpaolo at preciso dot net
php-4.0.6
postgres 7.1.2

I noticed a lot of sockets leaved in TIME_WAIT state in our application. so I worte a simple script

<pre>
for ($i = 0 $i < 100 ; $i++){
    $db = pg_open ("some string");
    pg_close($db);
}
<pre>

After that I noticed around 200 sockets in TIME _WAIT state. If I omit the pg_close statement averything works fine (and is considerably faster).
The same thing happens if I do a query before reopen a connection.
This bug is not reproducible with postgres 7.0.x

Thanks and goodbye

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-13 08:12 UTC] thies@php.net
this is not a bug in php. here's the reply from 
Jan Wieck (PostgreSQL core guy) also read 
http://globecom.net/ietf/draft/draft-faber-time-wait-avoidance-00.html


    AFAIK  TIME_WAIT is the status TCP/IP connections 
enter after
    successful close to hold the port number for some  
time  just
    in  case  there  are retransmit packets and the like 
still on
    the wire, so that no other process right now can bind 
to this
    port and gets confused when these orphaned packets 
arrive.
 
    Well,  on  127.0.0.1  this  doesn't  really make 
sense. And I
    think it can be avoided by using SO_REUSE, but I'm  
not  100%
    sure on that.
 
    OTOH  it's  only a real problem if you open/close 
many, many,
    many (and I really mean many) connections in  a  short 
 time.
    These  TIME_WAIT's disappear after a while and they 
don't eat
    bread  in  the  meantime.  So  if  you  don't  run   
out   of
    unprivileged ports, why worry about them?



 [2001-07-13 08:12 UTC] thies@php.net
this is not a bug in php. here's the reply from 
Jan Wieck (PostgreSQL core guy) also read 
http://globecom.net/ietf/draft/draft-faber-time-wait-avoidance-00.html


    AFAIK  TIME_WAIT is the status TCP/IP connections 
enter after
    successful close to hold the port number for some  
time  just
    in  case  there  are retransmit packets and the like 
still on
    the wire, so that no other process right now can bind 
to this
    port and gets confused when these orphaned packets 
arrive.
 
    Well,  on  127.0.0.1  this  doesn't  really make 
sense. And I
    think it can be avoided by using SO_REUSE, but I'm  
not  100%
    sure on that.
 
    OTOH  it's  only a real problem if you open/close 
many, many,
    many (and I really mean many) connections in  a  short 
 time.
    These  TIME_WAIT's disappear after a while and they 
don't eat
    bread  in  the  meantime.  So  if  you  don't  run   
out   of
    unprivileged ports, why worry about them?



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC