@wenshao 你好,想跟你请教个问题:
1、我的系统运行一段时间以后,就会报错:
[ERROR] [com.xxx.app.quartz.ToExamine] - org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7
增加maxActive的值也一样有问题,只是发生的时间间隔会加长而已。
是否在Quartz和Druid使用不当会造成连接池泄漏?二者如何配合使用?
2、详细错误:
[ERROR] [com.xxx.app.quartz.ToE] - org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7 org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7 at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) at org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:116) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:333) at $Proxy12.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:189) at org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:85) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:65) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38) at $Proxy36.selectReceipt(Unknown Source) at com.xxx.app.quartz.ToE.fr(ToExamine.java:67) at com.xxx.app.quartz.ToE.execute(ToExamine.java:51) at sun.reflect.GeneratedMethodAccessor291.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273) at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) at org.quartz.core.JobRunShell.run(JobRunShell.java:216) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: loopWaitCount 0, wait millis 60003, active 7 at com.alibaba.druid.pool.DruidDataSource.pollLast(DruidDataSource.java:1375) at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1019) at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:902) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4534) at com.alibaba.druid.filter.logging.LogFilter.dataSource_getConnection(LogFilter.java:827) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530) at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:884) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:92) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) ... 18 more
3、Druid版本:0.2.23;Quartz:1.8.5;
sql执行慢了,连接不够用,申请连接等待超时。druid是建议自己捕获这个异常,然后等待,还是采取鸵鸟策略,直接忽略这个异常?
<spanstyle="color:#333333;font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"><atarget="_blank"rel="nofollow">@wenshao<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> 上次发生问题以后,完全同样的代码,把数据库连接池换成Proxool以后已经稳定运行一周,而使用<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">Druid的话48小时内就会报这个错误。
<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">这个是由于慢SQL造成的吗?但是日志里面SQL执行时间基本是在5MS以下的,每秒处理的SQL不会超过20条,而我的连接个数配置为160了。
<spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"><spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">是不是连接池泄漏了?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。