Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

Questions : Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

8867

After starting my SpringBoot application, in4codes_hikaricp getting an exception on few minutes of the in4codes_hikaricp server startup. Did not use any HikariPool in4codes_hikaricp Configuration externally, Spring Boot is in4codes_hikaricp using HikariPool by default This is the in4codes_hikaricp error I am getting in the console:

2020-02-20 03:16:23 - HikariPool-4 - Failed to validate connection [email protected]4c4180c8 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-02-20 03:16:28 - HikariPool-4 - Failed to validate connection [email protected]679c2f50 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-02-20 03:16:33 - HikariPool-4 - Failed to validate connection [email protected]16083061 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-02-20 03:16:38 - HikariPool-4 - Failed to validate connection [email protected]4fcaf421 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-02-20 03:16:43 - HikariPool-4 - Failed to validate connection [email protected]33df5d54 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-02-20 03:16:48 - HikariPool-4 - Failed to validate connection [email protected]373d288c (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value. 2020-02-20 03:16:48 - SQL Error: 0, SQLState: 08003 2020-02-20 03:16:48 - HikariPool-4 - Connection is not available, request timed out after 30156ms. 2020-02-20 03:16:48 - No operations allowed after connection closed. 2020-02-20 03:16:48 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause 

Total Answers 3
26

Answers 1 : of Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

The problem is that the default value of in4codes_hikaricp the spring.datasource.hikari.maxLifetime in4codes_hikaricp property (default of 30 minutes, in4codes_hikaricp https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby) in4codes_hikaricp is higher than the database’s in4codes_hikaricp wait_timeout, 10 minutes in my case. So in4codes_hikaricp you have two options, either decrease in4codes_hikaricp the hikari.maxLifetime below 10 minutes, in4codes_hikaricp or increase the database’s wait_timeout in4codes_hikaricp property.

0

1

Answers 2 : of Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

You can set the value as below in the in4codes_hikaricp application.properties file

spring.datasource.hikari.maxLifeTime : 600000 #10 minutes wait time 

0

3

Answers 3 : of Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

In my case, I solved the problem through in4codes_hikaricp this setting

@Configuration public class HikariSetting{ @Bean public HikariConfig config() { HikariConfig hikariConfig = new HikariConfig(); // other setting hikariConfig.addDataSourceProperty("socketTimeout", 600000); hikariConfig.setMaxLifetime(600000); return hikariConfig; } } 

reference this

0