Skip site navigation (1) Skip section navigation (2)

Bug (and fix): leaks of TCP connections when connected to a <7.4 server

From: Laurent Sylvain <sylvain(dot)laurent(at)elca(dot)ch>
To: "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Bug (and fix): leaks of TCP connections when connected to a <7.4 server
Date: 2004-06-21 13:00:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

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: line 304 and on:
	if (l_elen > 30000) {
		//if the error length is > than 30000 we assume this is
really a v2 protocol 
		//server so try again with a v2 connection
		//need to create a new connection and try again
			pgStream = new PGStream(p_host, p_port);
		catch (ConnectException cex)

A quick fix is to do a pgStream.close(); before instantiating a new
PGStream, but I don't know very well the sources and it might have other
side effects.

To circumvent the problem while waiting for an eventual new version of the
driver, I added "?compatible=7.3" to the connection URL...

I hope it'll improve the driver ;-)

Sylvain Laurent


pgsql-jdbc by date

Next:From: Markus SchaberDate: 2004-06-21 15:44:26
Subject: Re: blob without largeobject api
Previous:From: Dave CramerDate: 2004-06-21 12:53:41
Subject: Re: proposal for CallableStatements to handle multiple out

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group