Open andeb opened 10 months ago
I think changing schema/catalog shouldn't be part of transaction, it should be fixed at PG side.
I am also noticing this behavior with autoCommit=false
and a default schema when a connection is recreated due to maxLifetime
being reached, after which point the connection transaction state remains OPEN
and we would expect it to be IDLE because when we get the connection and try to set isolation level it now blows up with a "Cannot change transaction isolation level in the middle of a transaction` PSQLException
attached is the postgres logs for the initial connection creation and subsequently after maxLifetime
is reached and you can see hikari leaves the transaction open when autoCommit=false
auto_commit_false.txt
auto_commit_true.txt
in case it's not a duplicate, I created https://github.com/brettwooldridge/HikariCP/issues/2235
When HikariCP returns a connection to the pool, it calls
resetConnectionState
method, that will callsetSchema
if HikariCP is configured with a default schema and the schema was changed during the usage of the connection (more common when using multi-tenancy per schema pattern). This call from Hikari tosetSchema
will make the pgjdbc driver send aBEGIN
before executing theSET SESSION search_path
, leaving the pool with an active transaction in it.Should Hikari be sending a
commit
after changing the schemaautoCommit
isfalse
?More information on https://github.com/pgjdbc/pgjdbc/issues/3005
To Reproduce Run the application below: