HikariPool-1 - Connection is not available, request timed out after 30002ms.

1.确认配置:

 hikariDataSource.setIdleTimeout(60000); 
hikariDataSource.setConnectionTimeout(60000);
hikariDataSource.setValidationTimeout(3000);
hikariDataSource.setLoginTimeout(5);
hikariDataSource.setMaxLifetime(60000);

2. 确认sqlSession 有没有被最终关闭。catch后加入finally{SqlSession.close()}


3. I managed to fix it finally. The problem is not related to HikariCP.The problem persisted because of some complex methods in REST controllers executing multiple changes in DB through JPA repositories. For some reasons calls to these interfaces resulted in a growing number of "freezed" active connections, exhausting the pool. Either annotating these methods as@Transactional or enveloping all the logic in a single call to transactional service method seem to solve the problem.

最后我设法修复这个问题,发现和HikariCP无关。问题依然存在的原因是一些复杂的方法在其他控制器通过JPA存储多个数据库的造成的。由于某种原因调用这些接口导致越来越多的“冻结”活动连接,耗尽连接池。注释所调用的事务服务中如@Transactional中包含事务的所有逻辑的方法中解决这个问题。

参考链接:https://stackoverflow.com/questions/32968530/hikaricp-connection-is-not-available

你可能感兴趣的:(各种问题)