brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.98k stars 2.93k forks source link

HikariPool-2 - Connection is not available #1526

Open zhiliao666 opened 4 years ago

zhiliao666 commented 4 years ago

Hello, the pro environment found a large number of errors that could not obtain the connection to the database, like:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-2 - Connection is not available, request timed out after 30000ms.

The error may exist in class path resource [mapper/friends/write/WriteUfotoUserUnmatchFriendMapper.xml]

The error may involve com.ufoto.dao.write.WriteUfotoUserUnmatchFriendsMapper.selectByUids

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-2 - Connection is not available, request timed out after 30000ms.

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy186.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) at com.sun.proxy.$Proxy242.selectByUids(Unknown Source) at com.ufoto.manager.friends.UfotoUserFriendsManager.checkWasFriendBeforeAndDelMsg(UfotoUserFriendsManager.java:138) at com.ufoto.manager.friends.UfotoUserFriendsManager$$FastClassBySpringCGLIB$$d7f2c480.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684) at

open debug,found the connetion always Repeat loop creation:

image

What is the reason ???

jaehun2841 commented 4 years ago

Pool locking is suspect (Dead lock) Check the number of threads and the maximum pool size This occurs because a thread is not allocated a connection while a race condition occurs between threads.

brettwooldridge commented 4 years ago

@zhiliao666 @jaehun2841 See this link about pool locking.