线上应用偶发会出现GetConnectionTimeoutException(全都是active=0),并且一出现就有点停不下来(有时候持续几分钟,有时候持续几个小时)出现这个问题都比较偶然,跟流量大小似乎关系不大。而且出现这个问题后在这段时间内的getconnection()有1%的概率会出现这个超时(这个比例貌似和分库有关,但还不确定),与其同时其他的getConnection情况正常。 另外我有实现FilterEventAdapter,发现connection_connect的时候是很快的(都在5ms左右)。
现在这几个问题非常费解
active=0证明现在应该没有其他线程在用,也就是busy=0,但从数据上看这个datasource获取连接并不是一定失败的。 持续出现这个情况很奇怪,尤其是看监控似乎池子也没用满 connect速度很快,应该不会阻塞这么久 connect的次数很平缓(1分钟只有十次左右),如果连接不够用应该会一直在创建才对? 看到https://github.com/alibaba/druid/pull/4726 这个问题了,不过我的是mysql,而且connect的时候也没有任何异常,所以不是一个问题? Cause: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 5000, active 0, maxActive 60, creating 1, createElapseMillis 7051063; wait millis 5000, active 0, maxActive 60, creating 1, createElapseMillis 7051063; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 5000, active 0, maxActive 60, creating 1, createElapseMillis 7051063 at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:120) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 5000, active 0, maxActive 60, creating 1, createElapseMillis 7051063 at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1738) at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1408) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5059) at com.xx.xx.xx.druid.filter.XxxDruidMonitorFilter.dataSource_getConnection(BcfDruidMonitorFilter.java:52)