Search code examples
oracle-databasetransactionsmicroserviceshikaricp

Long transactions block active connections in HikariCP


I've faced with the problem when Java Service (HikariCP+JDBC+Oracle, pool=10) has big transaction which includes DB operations and external Services calls, during running this transaction Hikari reserves connection (at least shows it via JMX) until transaction is finished. As trasaction is long due to Service calls (it's not possible to exclude it from transaction, I've already minimized timeout) active connection is reserved for too long, it blocks all Service.

Threads are blocked on getConnection().

The main thing here is that Active connection is only on Hikari but not on Oracle side, Oracle shows it as inactive. E.g. Hikari is wasting connection as in reality it's not doing anything with DB.

Is there any configuration in Hikari to resolve this issue? Or maybe some pattern how to avoid it?


Solution

  • After updating Hikari to the latest version it was resolved (there were a few releases where it was mentioned fixes for threads issue), additionally to be on the safe side maxLifetime has been set on our side, works ok for now.