您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> druid连接不释放问题

druid连接不释放问题

来源:网络整理     时间:2016/5/26 2:14:00     关键词:uid,rui

关于网友提出的“druid连接不释放问题”问题疑问,本网通过在网上对“druid连接不释放问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:druid连接不释放问题
描述:

@wenshao 你好,想跟你请教个问题:

1:最近我在用druid做项目时碰到一个问题,应用在访问一段时间后会出现数据连接不响应,应用无响应现象,必须重启才可以继续使用,通过查看监控平台看到逻辑连接打开次数=87,逻辑连接关闭次数为61,两者不相等,连接池中连接数为0,是不是表示泄漏?

druid连接不释放问题   2:我的配置文件如下,版本为1.0.9

druid连接不释放问题

3:此时weblogic控制台打印错误如下:

 "[STUCK] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@1cfa3bae WAITING
          
            sun.misc.Unsafe.park(Native Method)
          
            java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
          
            java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
          
            com.alibaba.druid.pool.DruidDataSource.takeLast(DruidDataSource.java:1348)
          
            com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1023)
          
            com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:898)
          
            com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)
          
            com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)
          
            com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
          
            com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:880)
          
            com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)
          
            com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)
          
            org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)

3:应用日志打印如下:

<2014-11-23 下午05时58分51秒 CST> <Error> <WebLogicServer> <BEA-000337> <[STUCK] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "687" seconds working on the request "weblogic.servlet.internal.ServletRequestImpl@1ddb5485[
POST /CRM_WH/servlet/CommonServlet HTTP/1.1
x-requested-with: XMLHttpRequest
Accept-Language: zh-cn
Referer: http://133.64.103.7:7012/CRM_WH/jsp/procedure/commonProcedureCall.jsp?menue_attr_id=8020
Accept: */*
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)
Content-Length: 329
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=YgXcJvhJbg3Z7LHvTLhvSyGzhZMnJlN2LnM3LQZ2nZQDyRqfpYyQ!-464481048
]", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
com.alibaba.druid.pool.DruidDataSource.takeLast(DruidDataSource.java:1348)
com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1023)
com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:898)
com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)
com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)
com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:880)
com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)
com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)
org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:214)
$Proxy63.prepareStatement(Unknown Source)
sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:53)
$Proxy64.prepareStatement(Unknown Source)
com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:497)
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:75)
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
org.springframework.orm.ibatis.SqlMapClientTemplate$8.doInSqlMapClient(SqlMapClientTemplate.java:366)
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)
org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)
com.tydic.crm.wh.dao.impl.CommonDaoImpl.insert(CommonDaoImpl.java:120)
sun.reflect.GeneratedMethodAccessor98.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy62.insert(Unknown Source)
com.tydic.crm.wh.component.LogInterceptor.doAccessCheck(LogInterceptor.java:59)
sun.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:603)
org.springframework.aop.aspectj.AspectJMethodBeforeAdvice.before(AspectJMethodBeforeAdvice.java:39)
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:49)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy62.callProcedure(Unknown Source)
com.tydic.crm.wh.servlet.CommonServlet.doPost(CommonServlet.java:77)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:124)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

5:系统运行一段时间 后出现:

com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 30000, active 20, runningSqlCount 3 :

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:268)
at com.tydic.crm.wh.dao.impl.CommonDaoImpl.qryMapInfo(CommonDaoImpl.java:28)
at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy62.qryMapInfo(Unknown Source)

6:还有一个问题,如果应用中有些SQL执行时间太长,超过weblogic设置的超时时间(假如60S),进行被回收后,数据库连接是否不会释放,导致泄露?

 以上是我做项目遇到的一些问题,请您帮助,如果有不对的地方还请不吝赐教。


解决方案1:

这个肯定是有connection没有close,你仔细查一下,我也是这样,后来关闭了就好了,两者相等。现在的问题是,我的sqlserver里面用sp_who查看连接时,还是有近200的连接,状态为sleeping,求解!

解决方案2:

https://github.com/alibaba/druid/wiki/%E8%BF%9E%E6%8E%A5%E6%B3%84%E6%BC%8F%E7%9B%91%E6%B5%8B

解决方案3:

你应该是有连接打开了没有关闭

解决方案4:

没有等到合适的回复,自己顶一下

解决方案5:

先专注一下,我的应用数据库连接也会出问题,还没找时间排查


以上介绍了“druid连接不释放问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1311525.html

相关图片

相关文章