Re: Idle connections / sessions - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject Re: Idle connections / sessions
Date
Msg-id puqlq7$rlc$1@blaine.gmane.org
Whole thread Raw
List pgsql-jdbc
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



pgsql-jdbc by date:

Previous
From: Sehrope Sarkuni
Date:
Subject: [pgjdbc/pgjdbc] 9b45e7: refactor: Clean up loading of reading ofkeydata f...
Next
From: Dave Cramer
Date:
Subject: [pgjdbc/pgjdbc] 2a639f: Update README.md