pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
Cc: List <pgsql-jdbc@postgresql.org>
Subject: Re: Could pgsql jdbc support pool reauthentication?
Date: Tue, 31 Oct 2017 12:51:18 +0200
Message-ID: <9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com> (raw)
In-Reply-To: <CAB=Je-F1rFGM+-DFHgGWdBxQ_R3=Ptqf9iUyEBndE3pDiYGyaA@mail.gmail.com>
References: <74d59bcf-cc4f-3a61-cf0a-8ab3ed5ca9aa@matrix.gatewaynet.com>
	<CAB=Je-Ge3LdLJMwsz0+GeT9T1KL0wXymUX206Y22K8+iYpsnWw@mail.gmail.com>
	<09a677fd-144f-6b16-57a8-ed6a18f3ff08@matrix.gatewaynet.com>
	<CAB=Je-F1rFGM+-DFHgGWdBxQ_R3=Ptqf9iUyEBndE3pDiYGyaA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

On 31/10/2017 11:20, Vladimir Sitnikov wrote:
> Achilleas>I know, but we still risk having our max_connections exceeded.
>
> You should limit the work at thread pool level, not at connection pool level.
> That is you should not accept new tasks for execution if they might block on a "getConnection" call.
>
Problem is one single java thread might use all 5 connections, depending on the app. And as each connection is closed, it is returned to the private user's pool, where it will stay until idle-timeout 
expires and kills the backend . Till that happens, no one else can use this, which is clearly a poor management of resources.
> Imagine a case:
> 1) Thread A starts a transaction, it calls the DB
> 2) Thread B starts processing another request, it locks some Java lock and calls .getConnection. Unfortunately, there's not enough connections, sot it just waits.
> 3) Thread A completes the DB call, it continues and tries to take the same Java lock.
>
> Now we have a deadlock: A is waiting for the Java lock and it holds a DB connection (with uncommitted transaction), while B is holding a Java lock and it is trying to get a connection.
A buggy application will manifest its problems sooner or later
>
> That is, it is not connection pool's task to limit the number of concurrent requests.
>
> Achilleas>And this is not scaleable.
>
> Can you elaborate?
As described in the first sentence above, this design is not flexible. One should lower idle-timeout to effectively zero, solving the problem of poor management, but effectively loosing the benefits 
of having a connection pool in the first place.

That's why reauth plugins was introduced in JCA spec.

>
> Vladimir


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt



-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (16+ messages)  latest in thread

Message-ID: <9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com>
Permalink:  ../9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: achill@matrix.gatewaynet.com, sitnikov.vladimir@gmail.com
  Subject: Re: Could pgsql jdbc support pool reauthentication?
  In-Reply-To: <9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com>
  References: <74d59bcf-cc4f-3a61-cf0a-8ab3ed5ca9aa@matrix.gatewaynet.com> <CAB=Je-Ge3LdLJMwsz0+GeT9T1KL0wXymUX206Y22K8+iYpsnWw@mail.gmail.com> <09a677fd-144f-6b16-57a8-ed6a18f3ff08@matrix.gatewaynet.com> <CAB=Je-F1rFGM+-DFHgGWdBxQ_R3=Ptqf9iUyEBndE3pDiYGyaA@mail.gmail.com> <9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox