Re: Connection Pool Timeout

From: Kris Jurka <books(at)ejurka(dot)com>
To: Neil Murray <nhm(at)mimecast(dot)net>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Connection Pool Timeout
Date: 2004-01-11 21:56:36
Message-ID: Pine.LNX.4.33.0401111639550.5953-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Tue, 23 Dec 2003, Neil Murray wrote:

> Hi,
>
> I connect to the DB with pg73jdbc3.jar - and I make use of
> Jdbc3PoolingDataSource().
>
> Using the connection pool is no problem, but there seems to be a black hole
> of access at the point where the getConnection() method is called. If
> getConnection is called, and no DB connections are available, then
> getConnection() waits forever without throwing an exception. The API seems
> to indicate that there is a timeout that can be set, but setting it has made
> no difference. getConnection() still waits forever.

The setLoginTimeout method is just a stub and the comment for it indicates
that it is not implemented. There are two issues with its implementation.
Regarding your problem that the pool is empty and it loops forever waiting
for a connection to be made available, it would be a pretty simple fix to
count the number of loops made and bail out once you've passed the
timeout.

The other problem is actually enforcing this connection timeout when
creating a real connection. As far as I can see there is no means before
the 1.4 jvm to put a timeout value on creating a Socket connection.
Then for the whole connection and authentication process you would need to
call setSoTimeout on the Socket. This would be incredibly ugly because to
enfore a setLoginTimeout of 4 seconds you couldn't simply use a 4 second
timeout on the socket's read and write calls because each one of many
could take 3.9 seconds. You would have to continually monitor the time
elapsed and keep calling setSoTimeout with the remaing time left.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-01-11 22:14:01 Re: jdbc pooling question
Previous Message Marcus Andree S. Magalhaes 2004-01-11 21:52:07 Re: jdbc pooling question