brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
20k stars 2.93k forks source link

Postgres Connection left in OPEN transaction when autoCommit=false and maxLifetime is reached #2235

Open kevinchan-rl opened 2 months ago

kevinchan-rl commented 2 months ago

Hi,

We noticed our connection pool becomes unusable after maxLifetime has been reached with runtime exception PSQLException: Cannot change transaction isolation level in the middle of a transaction when trying to set the isolation level the first time after getting the connection from the datasource. We are using exposed 0.51 in kotlin.

We have autoCommit=false and default schema set on the hikari datasource.

Attached are the postgres logs for when autoCommit=false and autoCommit=true and you can see the connection init for both the first time and when maxLifetime is reached. Notice that the transaction is left open when autoCommit=false when maxLifetime is reached.

kevinchan-rl commented 2 months ago

auto_commit_false.txt auto_commit_true.txt

kevinchan-rl commented 2 months ago

potentially a duplicate of https://github.com/brettwooldridge/HikariCP/issues/2144

quaff commented 1 month ago

potentially a duplicate of #2144

It's a duplicate and should be fixed at PostgreSQL JDBC Driver side, see https://github.com/pgjdbc/pgjdbc/issues/3005