Re: Connection Pool Timeout

Поиск
Список
Период
Сортировка
От Marcus Andree S. Magalhaes
Тема Re: Connection Pool Timeout
Дата
Msg-id 61064.200.174.148.100.1073861045.squirrel@webmail.webnow.com.br
обсуждение исходный текст
Ответ на Re: Connection Pool Timeout  (Kris Jurka <books@ejurka.com>)
Ответы Re: Connection Pool Timeout  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
> 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.
>

Yup. That would be simple to do.

> 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
>

Kris, checking Sun's javadoc pages, it seemes that setSoTimeout and
setSoLinger is abailable since jdk 1.1. My guess is, if anyone wants
to provide a solution to this "problem", the best answer would be to
use both the loop limit and socket timeouts.

I was thinking in something like the following:

 - a higher value to setSoTimeout when initializing/connecting the
   sockets

 - after the sockets are connected and available to the pooling
   structure, set a higher/infinite value to SO_TIMEOUT and,
   probably, suitable value to SO_LINGER

 - put a max value by counting the number of wait() calls inside the
   loop and maybe raise an exception.

This way, the client has the control to either log an error or
try to get a new connection over and over again.

Don't know if this can be easily done. Can't say for sure if
the org.postgresql.Driver provides the ways to control the sockets
there are used to connect to the backend.

> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html




В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Oliver Jowett
Дата:
Сообщение: Re: PreparedStatement parameters and mutable objects
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: Connection Pool Timeout