Sobes.tech
Senior

Hikari Pool with 10 connections, under load, received 'connections not available'. What to do?

sobes.tech AI

Answer from AI

The error "connections not available" in HikariCP with a pool of 10 connections means that all available connections are busy and new requests cannot obtain a connection from the pool.

What to do:

  • Increase the pool size (for example, increase maxPoolSize) if the load truly requires more connections.
  • Check that connections are properly closed (the close() method is called on Connection), otherwise they remain occupied.
  • Analyze the lifetime and timeout of connections (connectionTimeout), possibly increase the timeout.
  • Optimize queries and transactions to occupy connections for as short a time as possible.
  • Enable HikariCP logging to detect connection leaks (leakDetectionThreshold).

Example of increasing the pool size:

HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(20); // increase pool to 20
HikariDataSource ds = new HikariDataSource(config);

It is important to ensure that the database and infrastructure can handle the increased number of connections.

Hikari Pool with 10 connections, under load, received… - sobes.tech