HikariPool-2-无法验证连接

时间:2019-12-24 04:50:33

标签: mysql spring spring-boot connection-pool

我是Spring Boot的新手,所以对application.properties或pom.xml中的配置了解不多。我正在尝试在Azure VM中托管的MySQL DB中执行CRUD操作。一旦启动spring-boot应用程序并执行DB操作,它在第一次就可以正常工作。片刻之后,例如4-5分钟,当执行另一项操作时,springboot应用程序将无法连接到数据库并引发Exception。

PSB日志:

2019-12-23 14:43:00.063 DEBUG 64148 --- [http-nio-4400-exec-5] o.s.web.servlet.DispatcherServlet        : GET "/rest/path/getFrequentDetail?queryParam1=value1&queryParam2=value2", parameters={masked}
2019-12-23 14:43:00.063 DEBUG 64148 --- [http-nio-4400-exec-5] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to public org.springframework.http.ResponseEntity<com.bla.bla> com.bla.bla(java.lang.String,java.lang.String) throws java.io.IOException
2019-12-23 14:43:00.064 DEBUG 64148 --- [http-nio-4400-exec-5] o.h.e.t.internal.TransactionImpl         : On TransactionImpl creation, JpaCompliance#isJpaTransactionComplianceEnabled == false
2019-12-23 14:43:00.064 DEBUG 64148 --- [http-nio-4400-exec-5] o.h.e.t.internal.TransactionImpl         : begin
2019-12-23 14:43:05.073  WARN 64148 --- [http-nio-4400-exec-5] com.zaxxer.hikari.pool.PoolBase          : HikariPool-2 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@503a164d (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2019-12-23 14:43:10.077  WARN 64148 --- [http-nio-4400-exec-5] com.zaxxer.hikari.pool.PoolBase          : HikariPool-2 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@56e33182 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2019-12-23 14:43:15.079  WARN 64148 --- [http-nio-4400-exec-5] com.zaxxer.hikari.pool.PoolBase          : HikariPool-2 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@43689c2d (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2019-12-23 14:43:20.082  WARN 64148 --- [http-nio-4400-exec-5] com.zaxxer.hikari.pool.PoolBase          : HikariPool-2 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@306934d0 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2019-12-23 14:43:25.085  WARN 64148 --- [http-nio-4400-exec-5] com.zaxxer.hikari.pool.PoolBase          : HikariPool-2 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@7754c08f (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2019-12-23 14:43:30.087  WARN 64148 --- [http-nio-4400-exec-5] com.zaxxer.hikari.pool.PoolBase          : HikariPool-2 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@3a33fdce (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2019-12-23 14:43:30.091 DEBUG 64148 --- [http-nio-4400-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper   : Unable to acquire JDBC Connection [n/a]
java.sql.SQLTransientConnectionException: HikariPool-2 - Connection is not available, request timed out after 30024ms.
        at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:697)

application.properties

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Hikari parameters
spring.datasource.hikari.connectionTimeout=30000
spring.datasource.hikari.idleTimeout=600000
spring.datasource.hikari.maxLifetime=1800000

spring.datasource.initialize=true
spring.datasource.schema=classpath:schema.sql
spring.batch.initialize-schema=ALWAYS
spring.batch.job.enabled: false

我已经在互联网上搜索了类似的问题,并且主要与连接保持打开或MySQL超时配置有关。 就我而言,这两个都不错。

所有操作均使用JPA完成。 mysql中的超时很高:

  • innodb_lock_wait_timeout 50
  • wait_timeout 28800
  • mysqlx_wait_timeout 28800

请帮助。

0 个答案:

没有答案
相关问题