Re: Bug (and fix): leaks of TCP connections when connected

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Laurent Sylvain <sylvain(dot)laurent(at)elca(dot)ch>, "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Bug (and fix): leaks of TCP connections when connected
Date: 2004-06-22 01:42:32
Message-ID: 8806.1087868552@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Kris Jurka <books(at)ejurka(dot)com> writes:
> I'm not much of an expert on TCP, so could you give me a little more
> background on this? I've duplicated the behavior you describe and I
> believe your fix is correct, but I'd like to understand this better.
> First why is this a problem, the CLOSE_WAIT entries disappear rather
> quickly. Second the number of CLOSE_WAIT items is nothing compared to the
> number of TIME_WAIT entries, why aren't they a problem?

I think CLOSE_WAIT means that the kernel knows the far end has closed
the connection, but it's not yet been able to tell the local client so
(the vice-versa case may be called this too, not sure). This state can
persist indefinitely if the client is uncooperative. TIME_WAIT is a
short-lived state; the connection will be forgotten completely after the
timeout, which I think is order-of-a-minute. (TIME_WAIT exists only so
that the kernel remembers what to do with any delayed packets that may
arrive from the far end.)

Bottom line is that CLOSE_WAIT means that a client bug is keeping the
kernel from freeing resources. You don't want to see that.

regards, tom lane

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-06-22 02:03:38 Re: Bug (and fix): leaks of TCP connections when connected
Previous Message Kris Jurka 2004-06-21 22:50:25 Re: JDBC driver inserting into a table with Bytea type get