Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gX1Ex-0002M2-9r for pgsql-jdbc@arkaria.postgresql.org; Wed, 12 Dec 2018 09:55:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gX1Ev-0005nP-Se for pgsql-jdbc@arkaria.postgresql.org; Wed, 12 Dec 2018 09:55:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gX1Ev-0005lo-JS for pgsql-jdbc@lists.postgresql.org; Wed, 12 Dec 2018 09:55:37 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gX1Es-0001gr-KN for pgsql-jdbc@postgresql.org; Wed, 12 Dec 2018 09:55:36 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gX1Ch-0007Vy-6P for pgsql-jdbc@postgresql.org; Wed, 12 Dec 2018 10:53:19 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: Idle connections / sessions Date: Wed, 12 Dec 2018 10:55:22 +0100 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: Content-Language: en-GB Cc: pgadmin-support@postgresql.org,pgsql-sql@postgresql.org,pgsql-general@postgresql.org X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Oygun Josef schrieb am 12.12.2018 um 10:37: > Is it possible to terminate idle connections/sessions automatically > through a timeout in AWS or do I need to run a periodical cron job > for this? > > Postgres version: 9.6.6 Instance: db.t2.micro RAM : 1GB > > We are running a microservice architecture using docker with > kubernetes and I can see that every pod on every node that has > connected to the DB still has a idle connection as long as the node > is still active even. An "idle" connection isn't really a problem. Long running "idle in transaction" session are a problem however. To cope with them, you could use idle_in_transaction_timeout: https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT > It is both PGAdmin and the PostgreSQL JDBC Driver that leaves open > idle connections. The JDBC driver does not leave any connections "open" or "idle" It's the application that uses the driver that fails to close them. Maybe you need to configure your connection pool to release connections when they are idle. Thomas