Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9U9I-0005zP-Nw for pgsql-jdbc@arkaria.postgresql.org; Tue, 31 Oct 2017 10:52:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e9U9I-0004TT-Am for pgsql-jdbc@arkaria.postgresql.org; Tue, 31 Oct 2017 10:52:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9U8m-0003JS-1h for pgsql-jdbc@postgresql.org; Tue, 31 Oct 2017 10:51:28 +0000 Received: from host3.dynacom.ondsl.gr ([62.103.35.211] helo=smadev.internal.net) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9U8i-0002WZ-HO for pgsql-jdbc@postgresql.org; Tue, 31 Oct 2017 10:51:27 +0000 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id v9VApIk7032322; Tue, 31 Oct 2017 12:51:18 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: Could pgsql jdbc support pool reauthentication? To: Vladimir Sitnikov Cc: List References: <74d59bcf-cc4f-3a61-cf0a-8ab3ed5ca9aa@matrix.gatewaynet.com> <09a677fd-144f-6b16-57a8-ed6a18f3ff08@matrix.gatewaynet.com> From: Achilleas Mantzios Message-ID: <9d07373e-694f-db6a-04cd-438d51a5f04e@matrix.gatewaynet.com> Date: Tue, 31 Oct 2017 12:51:18 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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