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

Поиск
Список
Период
Сортировка
От Laurent Sylvain
Тема Bug (and fix): leaks of TCP connections when connected to a <7.4 server
Дата
Msg-id A13B47F8EC3FD111A91500C04FD2A2820567E6FA@exchange.elca.ch
обсуждение исходный текст
Ответы Re: Bug (and fix): leaks of TCP connections when connected
Re: Bug (and fix): leaks of TCP connections when connected
Re: Bug (and fix): leaks of TCP connections when connected
Список pgsql-jdbc
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:

AbstractJdbc1Connection.java 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
        try
        {
            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 по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: proposal for CallableStatements to handle multiple out
Следующее
От: Markus Schaber
Дата:
Сообщение: Re: blob without largeobject api