Sobes.tech
Senior

Hikari Pool 10 ühendusega, koormuse all saime 'connections not available'. Mida teha?

sobes.tech AI

Vastus AI-lt

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.
  • Ensure that connections are properly closed (calling close() on the Connection), otherwise they remain occupied.
  • Analyze the lifetime and wait time 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 configuration to increase the pool:

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.