文档章节

c3p0 连接过多导致tomcat无法启动的解决方法

施长成
 施长成
发布于 2015/04/30 10:44
字数 597
阅读 31
收藏 0

错误:

WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner  com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@27e467f7 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
2015-04-30 10:29:43 WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner  com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@27e467f7 -- APPARENT DEADLOCK!!! Complete Status:
        Managed Threads: 3
        Active Threads: 3
        Active Tasks:
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6bd962a4 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@cdb344d (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@b46b1d3 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
        Pending Tasks:
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4e44996d
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@79b4eb3f
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@54c0b385
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@374a0c3b
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@5e6911d8
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4412ac54
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@25efe1b6
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@27cb872f
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@23183312
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@9c0f4be
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@5b03eaf2
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@5e35e48c
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@242fd3a6
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@3ff049d9
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@3880665a
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@75bfbbb0
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@7ebb5c34
Pool thread stack traces:
        Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
                java.net.PlainSocketImpl.socketConnect(Native Method)
                java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
                java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
                java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
                java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
                java.net.Socket.connect(Socket.java:579)
                java.net.Socket.connect(Socket.java:528)
                java.net.Socket.<init>(Socket.java:425)
                java.net.Socket.<init>(Socket.java:241)
                com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
                com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:293)
                com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2181)
                com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
                com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
                sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
                sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                java.lang.reflect.Constructor.newInstance(Constructor.java:526)
                com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
                com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
                com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
                com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
                com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
                com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
                com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
                com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
                com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
                com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
        Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
                java.net.PlainSocketImpl.socketConnect(Native Method)
                java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
                java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
                java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
                java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
                java.net.Socket.connect(Socket.java:579)
                java.net.Socket.connect(Socket.java:528)
                java.net.Socket.<init>(Socket.java:425)
                java.net.Socket.<init>(Socket.java:241)
                com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
                com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:293)
                com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2181)
                com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
                com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
                sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
                sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                java.lang.reflect.Constructor.newInstance(Constructor.java:526)
                com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
                com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
                com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
                com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
                com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
                com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
                com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
                com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
                com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
                com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
        Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]
                java.net.PlainSocketImpl.socketConnect(Native Method)
                java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
                java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
                java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
                java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
                java.net.Socket.connect(Socket.java:579)
                java.net.Socket.connect(Socket.java:528)
                java.net.Socket.<init>(Socket.java:425)
                java.net.Socket.<init>(Socket.java:241)
                com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
                com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:293)
                com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2181)
                com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
                com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
                sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
                sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                java.lang.reflect.Constructor.newInstance(Constructor.java:526)
                com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
                com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
                com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
                com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
                com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
                com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
                com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
                com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
                com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
                com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
                com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

解决方法:

    先关闭mysql数据库,然后在打开数据库,只限于测试环境,如果是正式环境请设置连接池的最大数量小于mysql的最大连接数量,而且不用mysql工具连接服务器,或者连接后及时关闭,减少连接数。

© 著作权归作者所有

共有 人打赏支持
施长成
粉丝 5
博文 66
码字总数 24419
作品 0
浦东
后端工程师
私信 提问
c3p0、dbcp、tomcat jdbc pool 连接池区别

查看资料,得知dbcp和c3p0都是单线程的,在高并发的环境下性能会非常低下, 决定换用tomcat自带的jdbc-pool,关于jdbc-pool的项目介绍。 区别参考链接:http://www.open-open.com/lib/view/o...

张嘴吃药
2017/10/30
0
0
关闭Tomcat时,是否要手动关闭c3p0创建出来的datasource

一个项目通过c3p0获得连接池,相关代码如下: 关闭Tomcat的时候提示: 主要是这几句: 1. 警告: The web application [uavmonitor] appears to have started a thread named [com.mchange.v2...

乐山ing
2017/02/13
436
3
tomcat JDBC连接池c3p0连接资源耗尽导致tomcat实例对应的app移动端无法访问。

tomcat app手机端程序无法打开了。 直接查看tomcat日志: [test@web01 logs]$ tail catalina.out at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at......

sandshell
2018/05/04
0
0
J-SUtil 1.1.3_1 实现与 c3po 分离

在之前的版本中不管开启不开启链接池,为了编译通过,都需要强制引入c3p0的jar包。此次 j-sUtil-1.1.3_1.jar版本实现与c3po分离,如果不需要c3p0链接池,可以完全不引入以下文件: ① config...

奋斗的麻雀
2015/04/09
334
0
数据库连接池DBCP和C3P0的使用

hibernate开发组推荐使用c3p0; spring开发组推荐使用dbcp; hibernate in action推荐使用c3p0; 一. dbcp 在数据库服务器强行关闭连接或数据库服务重启后,无法reconnect 二. dbcp 连接池的创建...

mn_1127
2015/08/27
0
0

没有更多内容

加载失败,请刷新页面

加载更多

mariadb 内存占用优化

本文由云+社区发表 作者:工程师小熊 摘要:我们在使用mariadb的时候发现有时候不能启动起来,在使用过程中mariadb占用的内存很大,在这里学习下mariadb与内存相关的配置项,对mariadb进行调...

腾讯云加社区
52分钟前
2
0
spring security 自定义登录认证

spring security 自定义认证登录 1.概要 1.1.简介 spring security是一种基于 Spring AOP 和 Servlet 过滤器的安全框架,以此来管理权限认证等。 1.2.spring security 自定义认证流程 1)认证...

EasyProgramming
53分钟前
1
0
PAI通过流式机器学习算法解决实时热点新闻挖掘案例

(机器学习PAI Online Learning模块上线邀测,目前只支持华北2(北京)区域使用,本实验会用到流式机器学习算法) PAI地址:https://data.aliyun.com/product/learn 邀测申请地址:https://dat...

阿里云官方博客
56分钟前
1
0
Win下Jenkins-2.138源码编译及填坑笔记

源码编译篇 1、 安装JDK1.8-181,操作系统添加JDK环境变量。Java -version验证一下。 注:Jenkins2.138版本,JDK必须jkd1.8.0-101以上,不支持Java9,Maven必须3.5.3以上。 2、 解压Maven3....

编程SHA
59分钟前
2
0
Oracle数据库常用函数 转换函数 日期函数 字符型函数 数值函数

在讲解函数的功能和用法之前,先了解一下dual这个表。 dual这个表是一张只有一个字段,一行记录的表。它是一个虚拟表,用来构成select的语法规则。所以我们接下来会用到这个表来讲解常用函数。...

Sakura20
59分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部