记一次应用配置的数据库连接被打满问题

线上应用,配置的数据库连接数为50,正常情况是已经够用了,但是有天发现50个连接全部被占满,并且长时间无法恢复,重启服务后会好一段时间。

1、问题现象

Druid获取MySQL数据库连接超时,超时时间设置的为60s

2019-09-23 15:38:24.627-|XNIO-3 task-80-|ERROR-|7fba6a1c917f42878b43f937df37e575-|10.123.18.241-|-|/api/v1/qimao/admin/distributor/add-|-|Java/1.8.0_181-|c.q.k.q.web.controller.admin.DistributorController-|method:addDistributor
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 10, maxActive 10, creating 0at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:289)at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:447)at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)at com.qiyi.kpp.qimao.web.service.impl.DistributorServiceImpl$$EnhancerBySpringCGLIB$$e95f0879.addDistributor(<generated>)at com.qiyi.kpp.qimao.web.controller.admin.DistributorController.addDistributor(DistributorController.java:174)at com.qiyi.kpp.qimao.web.controller.admin.DistributorController$$FastClassBySpringCGLIB$$9c955533.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)at com.qiyi.kpp.qimao.web.controller.admin.DistributorController$$EnhancerBySpringCGLIB$$100c45af.addDistributor(<generated>)at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source).............at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)at java.lang.Thread.run(Thread.java:745)
Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 10, maxActive 10, creating 0at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1512)at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1255)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5007)at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:680)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5003)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1233)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1225)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:90)at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:246)... 100 common frames omitted

2、解决办法

添加配置,当连接超过30秒钟后会强制进行回收

<!-- 超过时间限制是否回收 -->  
druid.removeAbandoned=true
<!-- 超时时间;单位为秒。 -->  
druid.removeAbandonedTimeout=30
<!-- 关闭abanded连接时输出错误日志 -->
druid.logAbandoned=true

最终重现了这个问题,打印日志如下

2019-09-27 16:07:21.369-|AsyncResolver-bootstrap-executor-0-|INFO-|-|-|-|-|-|-|c.n.d.shared.resolver.aws.ConfigClusterResolver-|Resolving eureka endpoints via configuration
2019-09-27 16:07:28.954-|Druid-ConnectionPool-Destroy-786728464-|ERROR-|-|-|-|-|-|-|com.alibaba.druid.pool.DruidDataSource-|abandon connection, owner thread: XNIO-3 task-862, connected at : 1569571561703, open stackTraceat java.lang.Thread.getStackTrace(Thread.java:1552)at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1313)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5007)at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:680)at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5003)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1233)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1225)at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:90)at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:246)at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:447)at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)at com.qiyi.kpp.qimao.web.service.impl.DistributorServiceImpl$$EnhancerBySpringCGLIB$$ec30275b.addDistributor(<generated>)at com.qiyi.kpp.qimao.web.controller.admin.DistributorController.addDistributor(DistributorController.java:174)at com.qiyi.kpp.qimao.web.controller.admin.DistributorController$$FastClassBySpringCGLIB$$9c955533.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)at com.qiyi.kpp.qimao.web.controller.admin.DistributorController$$EnhancerBySpringCGLIB$$34df12db.addDistributor(<generated>)

运行程序,当连接超过30秒钟后会强制进行回收,并输出异常日志。再根据异常日志分析(看看owner thread在干啥,为什么一直占据数据库连接)即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/313292.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Caffe阅读代码并修改

这个教程是最好理解的了 http://city.shaform.com/blog/2016/02/26/caffe.html 主要分成四個部份來講。首先是整個 Caffe 的大架構&#xff0c;以及一些重要的元件。 其次&#xff0c;我也研究了如何自己新增一個 layer。 接下來&#xff0c;再重新回到 Caffe 做更深入的解析…

ABP v1.0正式发布

经过长时间的开发终于发布了ABP v1.0&#xff01;感谢为该项目做出了贡献的你~https://github.com/abpframework/abp/releases

JVM解惑:消失的异常堆栈,log中打印异常堆栈为空

最近线上发现很多异常没有堆栈信息&#xff0c;只有一句描述&#xff0c;如下&#xff1a; java.lang.NullPointerException: null排查问题时受到了一些阻碍。然后发现无论是在本地环境还是测试环境&#xff0c;堆栈信息都可以正常打印&#xff0c;使用的是同一份日志配置文件…

Caffe自己修改训练方法

作者&#xff1a;Gein Chen链接&#xff1a;https://www.zhihu.com/question/27982282/answer/80242005&#xff11;&#xff0e;学习程序的第一步&#xff0c;先让程序跑起来&#xff0c;看看结果&#xff0c;这样就会有直观的感受。Caffe的官网上Caffe | Deep Learning Frame…

Ubuntu下用eclipse调试caffe code

本文地址&#xff1a;http://blog.csdn.net/mounty_fsc/article/details/51089864 1 运行范例脚本train_lenet.sh Ubuntu下终端行执行train_lenet.sh可训练lenet-5&#xff08;详细情况参考其他教程&#xff09;&#xff0c;能直观地看到lenet训练起来带情况。 train_lenet.sh…

idea使用jar包依赖,替换掉项目依赖

idea使用jar包依赖&#xff0c;替换掉项目依赖最近遇到了个问题&#xff0c;父子项目中&#xff0c;原本一个项目在idea下默认是项目依赖于另一个子项目&#xff0c;但是由于当前开发分支里不包含相应的代码&#xff0c;最新代码在别的分支&#xff0c;导致项目依赖时&#xff…

C#中Array.Sort()方法分析

Array.Sort()是在我们日常工作中非常常用的函数&#xff0c;不需要自己编写排序算法就可以方便的对数组进行排序。利用Array.Sort()排序具有以下特点&#xff1a;排序是不稳定的采用内省排序&#xff08;introspective sort&#xff09;这里简单解释一下内省排序。内省排序会先…

输入两个整数 n 和 m ,从数列 1 , 2 , 3.......n 中随意取几个数 ,使其和等于 m

转载自&#xff1a;http://blog.sina.com.cn/s/blog_7571423b01016707.html 编程求解&#xff1a;输入两个整数 n 和 m &#xff0c;从数列 1 &#xff0c; 2 &#xff0c; 3.......n 中随意取几个数 ,使其和等于 m , 要求将其中所有的可能组合列出来. 分析&#xff1a; 主要思…

张高兴的 .NET Core IoT 入门指南:(五)串口通信入门

在开始之前&#xff0c;首先要说明的是串口通信所用到的 SerialPort 类并不包含在 System.Device.Gpio NuGet 包中&#xff0c;而是在 System.IO.Ports NuGet 包中。之所以在这里介绍串口通信&#xff0c;是因为在嵌入式中串口通信是与其他设备进行交互的一种重要方式&#xff…

Caffe 在自己的数据库上训练步骤

回忆ImageNet的步骤&#xff1a;http://caffe.berkeleyvision.org/gathered/examples/imagenet.html Brewing ImageNet This guide is meant to get you ready to train your own model on your own data. If you just want an ImageNet-trained network, then note that sinc…

1024程序员节来啦!!.NET技术圈独家优惠劵,折后再折,赶紧来抢啊

1024程序员节当当网计算机图书每满100减50&#xff01;满200减100&#xff01;满300-150&#xff01;机械工业出版社华章公司联合当当网特意为【DotNET技术圈】用户申请了一批可与满减叠加使用的“满200减30”的图书优惠码&#xff0c;优惠码使用后相当于&#xff1a;400减230 …

Fine-tunning适用情况

https://www.quora.com/How-do-I-fine-tune-a-Caffe-pre-trained-model-to-do-image-classification-on-my-own-dataset 基本概念及举例&#xff1a; Deep Net or CNN like alexnet, Vggnet or googlenet are trained to classify images into different categories. Before t…

你跟最伟大领导的距离,或许只差这一点

译者&#xff1a;宗天琪原文链接&#xff1a;https://www.linkedin.com/pulse/great-leaders-listeners-brigette-hyacinth/?fromgroupmessage&isappinstalled0倾听是领导者需要掌握的最重要的技能&#xff0c;它是很多其它领导才能的基石。然而&#xff0c;要做到精通这项…

Batch_size问题

有关solver.prototxt中的各项解释&#xff1a;http://www.cnblogs.com/denny402/p/5074049.html solver算是caffe的核心的核心&#xff0c;它协调着整个模型的运作。caffe程序运行必带的一个参数就是solver配置文件。运行代码一般为 # caffe train --solver*_slover.prototxt 在…

程序员家的精品大闸蟹:青壳、白底、肉多、爆黄,现在是吃大闸蟹的最佳时期...

其实&#xff0c;我跟大家一样&#xff0c;也是dotNET跨平台和张队长的忠实粉丝&#xff0c;也是一名程序员。上上周&#xff0c;我在dotNET跨平台的优选商城买了队长推荐人生果&#xff0c;也是第一次吃这个人生果&#xff0c;味道鲜甜、汁水也特别多&#xff0c;但由于快递的…

C#刷遍Leetcode面试题系列连载(4): No.633 - 平方数之和

点击蓝字“dotNET匠人”关注我哟加个“星标★”&#xff0c;每日 7:15&#xff0c;好文必达&#xff01;前文传送门:上篇文章中一道数学问题 - 自除数&#xff0c;今天我们接着分析 LeetCode 中的另一道数学题吧~今天要给大家分析的面试题是 LeetCode 上第 633 号问题&#xff…

Caffe训练时出现了无数个Train net output #.....

尝试一种基于concatenation的网络结构&#xff0c;结果错把concatenation没接到下一步&#xff0c;训练时出现了无数个"Train net output #.....". 改了网络结构&#xff0c;同时又将原数据集合扩大到了六倍&#xff0c;结果发现迭代速度从4s降到了36s&#xff0c;尝…

程序员过关斩将--数据库的乐观锁和悲观锁并非真实的锁

菜菜哥&#xff0c;告诉你一个消息你有男票啦&#xff1f;非也非也&#xff0c;我昨天出去偷偷面试&#xff0c;结果又挂了哦&#xff0c;看来公司是真的不想让你走呀面试官让我说一下乐观锁和悲观锁&#xff0c;我没回答上来&#xff0c;回来之后我查了&#xff0c;数据库没有…

solverstate的使用

http://blog.csdn.net/wang4959520/article/details/51831637 我们在使用caffe训练过程中会生成.caffemodel和.solverstate文件&#xff0c;一个是模型文件&#xff0c;一个是中间状态文件&#xff08;生成多少个取决于你自己设定的snapshot&#xff09;。当训练过程中断&#…