Bug #12084 Updated: pg_close cause a lot of sockets in TIME_WAIT state
| From: | thies@php.net | Date: | Fri, 13 Jul 2001 12:12:06 +0000 |
| Subject: | Bug #12084 Updated: pg_close cause a lot of sockets in TIME_WAIT state | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-59953@lists.php.net to get a copy of this message | ||
ID: 12084
Updated by: thies
Reported By: gianpaolo@preciso.net
Status: Open
Bug Type: PostgreSQL related
Operating System: Debian 2.2
PHP Version: 4.0.6
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[2001-07-12 02:42:29] gianpaolo@preciso.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
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12084&edit=1