我在HikariCP中使用了springboot,但过了一段时间后,我的应用程序崩溃了,我得到了以下错误:
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
...
Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
....
Caused by: java.sql.SQLTransientConnectionException: HikariPool-6 - Connection is not available, request timed out after 30000ms.这是我的aplication.properties
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/db_dnaso
#spring.datasource.url=jdbc:postgresql://172.16.1.10:5432/db_dnaso
spring.datasource.username=postgres
spring.datasource.password=dna44100
spring.datasource.driver-class-name=org.postgresql.Driver所以我有很多对DB的保存,查找和其他访问,我如何可视化方法是如何阻塞我的连接的?
tks
发布于 2017-08-07 14:17:58
看起来你的数据库服务器快没连接了。Hikari中属性maximumPoolSize的默认值是10。这意味着它将在服务器启动时尝试创建10个连接,如果无法获取10个连接,它将不会启动,或者如果您的数据库服务器池大小在池中的连接较少,则可能会失败,因为您正在使用Hikari配置创建。如果您能够启动Spring Boot服务器,然后遇到这个问题,那么尝试启用leakDetectionThreshold,并检查哪个连接花费了更多时间,并且没有返回Hikari池。
spring:
datasource:
hikari:
leak-detection-threshold: 2000发布于 2017-06-27 19:48:16
启用leakDetectionThreshold,设置为大约1分钟(60000ms)。很可能你在某处有连接泄漏...连接被借用,但从未关闭(返回)。
发布于 2018-10-12 14:03:05
在springboot中,您可以在application.properties中设置spring.datasource.hikari.leak-detection-threshold=10000 (以毫秒为单位)。
maximumPoolSize的默认值是10。您可以使用spring.datasource.hikari.maximum-pool-size=xx进行更改。
https://stackoverflow.com/questions/44766968
复制相似问题