X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3E477D1B1B6 for ; Mon, 21 Jun 2004 22:42:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36546-04 for ; Tue, 22 Jun 2004 01:42:37 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6DFE1D1B18C for ; Mon, 21 Jun 2004 22:42:33 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5M1gX9G008807; Mon, 21 Jun 2004 21:42:33 -0400 (EDT) To: Kris Jurka Cc: Laurent Sylvain , "'pgsql-jdbc@postgresql.org'" Subject: Re: Bug (and fix): leaks of TCP connections when connected In-reply-to: References: Comments: In-reply-to Kris Jurka message dated "Mon, 21 Jun 2004 14:34:23 -0500" Date: Mon, 21 Jun 2004 21:42:32 -0400 Message-ID: <8806.1087868552@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/141 X-Sequence-Number: 10343 Kris Jurka 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