Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HikariPool-1 - Connection is not available, request timed out after 30000ms for very tiny load server

Tags:

I have a small Java application for testing purposes. I have moved to hikari recently. What I notice is that I keep getting this error.

java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms. java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms. at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:602) at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:195) at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:145) at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:85) 

Below is my settings for the hikari initially.

 HikariConfig config = new HikariConfig();             config.setJdbcUrl("jdbc:mysql://localhost:3306/****");              config.setUsername("***");              config.setPassword("*****");                   config.setMaximumPoolSize(20);   

Hardly its being used my two devices and I ensure towards the end I do close it. So I don't know why it keep getting the error? What could be the issue or is there some settings which I need to change?

My hikari version is HikariCP-2.6.1.jar.

like image 361
user8012596 Avatar asked Dec 11 '17 17:12

user8012596


People also ask

What is connection timeout in Hikari?

spring.datasource.hikari.connection-timeout=60000. Controls the maximum number of milliseconds that you will wait for setting up a connection from the pool. spring.datasource.hikari.idle-timeout=600000. Controls the maximum amount of time that a connection is allowed to sit idle in the pool.

What is maximum pool size in Hikari?

maximum-pool-size= 10 #maximum pool size spring. datasource. hikari. idle-timeout=10000 #maximum idle time for connection spring.

What is Hikari connection pool?

"HikariCP is solid high-performance JDBC connection pool. A connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools may significantly reduce the overall resource usage." - You can find out more here.

What is HikariConfig?

HikariConfig is the configuration class used to initialize a data source. It comes with four well-known, must-use parameters: username, password, jdbcUrl, and dataSourceClassName. Out of jdbcUrl and dataSourceClassName, we generally use one at a time.


1 Answers

Your database is not obtaining connection within (30000 milliseconds that is default connectionTimeout property) because of network latency or some of the queries which are taking too long to execute(more than 30000 milliseconds).

Please try to increase value of property connectionTimeout.

YML configuration example:

spring:   datasource:     hikari:       minimumIdle: 2       maximumPoolSize: 10       idleTimeout: 120000       connectionTimeout: 300000       leakDetectionThreshold: 300000 

Java Config example:

HikariConfig config = new HikariConfig();         config.setMaximumPoolSize(20);         config.setConnectionTimeout(300000);         config.setConnectionTimeout(120000);         config.setLeakDetectionThreshold(300000); 
like image 165
Girdhar Singh Rathore Avatar answered Oct 02 '22 21:10

Girdhar Singh Rathore