Druid出現DruidDataSource - recyle error - recyle error java.lang.InterruptedException: null異常排查與解決

1、問題回顧

線上的代碼以前運行的都很平穩,忽然就出現了一個很奇怪的問題,看錯誤信息是第三方框架Druid報出來了,鏈接池回收鏈接時出現的問題。html

2018-05-14 20:01:32.810 ERROR [hystrix-UpgradeResultReportController-49][DruidDataSource.java:1297] - recyle error java.lang.InterruptedException: null at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1220) ~[?:1.8.0_131] at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:335) ~[?:1.8.0_131] at com.alibaba.druid.pool.DruidDataSource.recycle(DruidDataSource.java:1279) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.pool.DruidPooledConnection.recycle(DruidPooledConnection.java:292) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4534) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.filter.FilterAdapter.dataSource_releaseConnection(FilterAdapter.java:2717) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4530) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.filter.stat.StatFilter.dataSource_releaseConnection(StatFilter.java:646) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4530) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.pool.DruidPooledConnection.syncClose(DruidPooledConnection.java:269) [druid-1.0.11.jar!/:1.0.11] at com.alibaba.druid.pool.DruidPooledConnection.close(DruidPooledConnection.java:228) [druid-1.0.11.jar!/:1.0.11] at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:341) [spring-jdbc-4.3.8.RELEASE.jar!/:4.3.8.RELEASE] at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328) [spring-jdbc-4.3.8.RELEASE.jar!/:4.3.8.RELEASE] at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:294) [spring-jdbc-4.3.8.RELEASE.jar!/:4.3.8.RELEASE] at org.mybatis.spring.transaction.SpringManagedTransaction.close(SpringManagedTransaction.java:127) [mybatis-spring-1.3.1.jar!/:1.3.1] at org.apache.ibatis.executor.BaseExecutor.close(BaseExecutor.java:90) [mybatis-3.4.2.jar!/:3.4.2] at org.apache.ibatis.executor.CachingExecutor.close(CachingExecutor.java:64) [mybatis-3.4.2.jar!/:3.4.2] at org.apache.ibatis.session.defaults.DefaultSqlSession.close(DefaultSqlSession.java:264) [mybatis-3.4.2.jar!/:3.4.2] at org.mybatis.spring.SqlSessionUtils.closeSqlSession(SqlSessionUtils.java:193) [mybatis-spring-1.3.1.jar!/:1.3.1] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:454) [mybatis-spring-1.3.1.jar!/:1.3.1] at com.sun.proxy.$Proxy133.update(Unknown Source) [?:?] at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294) [mybatis-spring-1.3.1.jar!/:1.3.1] at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) [mybatis-3.4.2.jar!/:3.4.2] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) [mybatis-3.4.2.jar!/:3.4.2] at com.sun.proxy.$Proxy148.updDeviceUpgradeStatus(Unknown Source) [?:?] at com.phicomm.smarthome.ota.service.impl.UpgradeHistoryDaoServiceImpl.updUpgradeSuccessStatus(UpgradeHistoryDaoServiceImpl.java:50R [classes!/:0.0.1-SNAPSHOT] at com.phicomm.smarthome.ota.service.impl.UpgradeHistoryDaoServiceImpl$$FastClassBySpringCGLIB$$9b468fba.invoke(<generated>) [classes!/:0.0.1-SNAPSHOT] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) [spring-aop-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]

2、排查問題

查看一下他的源碼java

看了一下也沒有發現因此然,而後去GitHub上的Druid官方開源處,看了一下歷史問題修復,發現這個是舊版本已知的一個Buggit

https://github.com/alibaba/druid/issues/785github

看了一下當前使用的Druid的版本【1.0.11】,而後又確認了一下官方最新的版本是【1.1.9】,已經差了不少個版本了。spring

果斷將版本更新至最新數據庫

<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.9</version> </dependency>

翻看以前出錯的那裏的代碼發現apache

 更新到最新版本後,上述問題獲得解決。session

數據庫鏈接被中斷的緣由有不少,有一種是初始化配置時設置的數據庫鏈接回收時長,經過datasource.getConnontion() 取得的鏈接必須在removeAbandonedTimeout這麼多秒內調用close(),不然就主動將其殺死,就是conn不能超過指定的租期。mybatis

詳細配置能夠參考這篇文章:app

https://my.oschina.net/haogrgr/blog/224010

相關文章
相關標籤/搜索