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

From: Laurent Sylvain <sylvain(dot)laurent(at)elca(dot)ch>
To: 'Oliver Jowett' <oliver(at)opencloud(dot)com>
Cc: "'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 07:15:57
Message-ID: A13B47F8EC3FD111A91500C04FD2A2820567E6FD@exchange.elca.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

There's no finalizer on the Socket class that closes it so that even if it
is garbage collected, the socket is not closed at the OS level. I think I
saw somewhere this was done by design and actually I believe it's much
cleaner to properly close the socket before losing any reference to it so
that OS resources are freed as early as possible. Much better for
scalability ;-)
My java program ran for days so that I'm pretty sure GC occurred. Anyway
when I performed a netstat I had hundreds of connections waiting to be
closed...

Sylvain

-----Original Message-----
From: Oliver Jowett [mailto:oliver(at)opencloud(dot)com]
Sent: mardi, 22. juin 2004 04:04
To: Laurent Sylvain
Cc: 'pgsql-jdbc(at)postgresql(dot)org'
Subject: Re: [JDBC] Bug (and fix): leaks of TCP connections when
connected to a <7.4 server

Laurent Sylvain wrote:
> Hello,
>
> I experienced some TCP connection leaks when using PGSQL JDBC driver 7.4
> (build 214) to connect to a 7.3.4 server.
> The symptoms are that when performing a netstat on the client machine,
many
> connections were in the CLOSE_WAIT state.
>
> The problem is that the driver tries to connect using v3 protocol and when
> it sees that the server doesn't understand it, it opens a new connection
> (PGStream) to the server without closing the previous one:

In theory the discarded connections should eventually be garbage
collected and closed, right? So at least the leak is bounded.

(I'll check that this is fixed in my patches; I restructured that area
quite a bit)

-O

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-06-22 09:37:15 Re: Bug (and fix): leaks of TCP connections when connected
Previous Message Oliver Jowett 2004-06-22 03:42:53 Re: Bug (and fix): leaks of TCP connections when connected