首页

发生错误" Connections could not be acquired from the underlying database!"

标签:java,异常,mysql,连接数过大,max_connection_errors,exception,MySQL,error,exception     发布时间:2015-10-13   

一、问题现象

因超过mysql数据库max_connection_errors的最大值,中断数据库连接而导致阻塞

[INFO] Scanning for projects...@b@[WARNING] @b@[WARNING] Some problems were encountered while building the effective model for com.ekache:cvp_portal:war:0.0.1-SNAPSHOT@b@[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: javax.servlet:jstl:jar -> duplicate declaration of version 1.2 @ line 87, column 15@b@[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 106, column 12@b@[WARNING] @b@[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.@b@[WARNING] @b@[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.@b@[WARNING] @b@[WARNING] The POM for org.apache.maven.plugins:maven-site-plugin:jar:2.0.1 is missing, no dependency information available@b@[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:2.0.1: Plugin org.apache.maven.plugins:maven-site-plugin:2.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:2.0.1@b@[INFO]                                                                         @b@[INFO] ------------------------------------------------------------------------@b@[INFO] Building cvp_portal 0.0.1-SNAPSHOT@b@[INFO] ------------------------------------------------------------------------@b@[WARNING] The POM for org.apache.maven.plugins:maven-site-plugin:jar:2.0.1 is missing, no dependency information available@b@[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:2.0.1: Plugin org.apache.maven.plugins:maven-site-plugin:2.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:2.0.1@b@[INFO] @b@[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ cvp_portal >>>@b@[WARNING] The artifact jexcelapi:jxl:jar:2.6 has been relocated to net.sourceforge.jexcelapi:jxl:jar:2.6@b@[INFO] @b@[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ cvp_portal ---@b@[INFO] Using 'UTF-8' encoding to copy filtered resources.@b@[INFO] skip non existing resourceDirectory C:NJJSPACECVP_Portalsrcmain@b@esources@b@[INFO] @b@[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ cvp_portal ---@b@[INFO] Nothing to compile - all classes are up to date@b@[INFO] @b@[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ cvp_portal <<<@b@[WARNING] The artifact jexcelapi:jxl:jar:2.6 has been relocated to net.sourceforge.jexcelapi:jxl:jar:2.6@b@[INFO] @b@[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ cvp_portal ---@b@[INFO] Running war on http://localhost:8089/cvp_portal@b@[INFO] Creating Tomcat server configuration at C:NJJSPACECVP_Portal    arget    omcat@b@2015-10-13 21:05:45 org.apache.catalina.startup.Embedded start@b@信息: Starting tomcat server@b@2015-10-13 21:05:45 org.apache.catalina.core.StandardEngine start@b@信息: Starting Servlet Engine: Apache Tomcat/6.0.29@b@[Portal] @b@2015-10-13 21:06:06@b@[WARN]-[Thread: Timer-0]-[com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run()]: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@2dd7e4d6 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!@b@[Portal] @b@2015-10-13 21:06:06@b@[WARN]-[Thread: Timer-0]-[com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run()]: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@2dd7e4d6 -- APPARENT DEADLOCK!!! Complete Status: @b@    Managed Threads: 3@b@    Active Threads: 3@b@    Active Tasks: @b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1a07ac6c (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6dc8f3cd (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@23fe500a (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)@b@    Pending Tasks: @b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@d38d2fc@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@da3a52c@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@72b0f2b2@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@3f0dbef1@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1f72e08e@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@2ef49ac3@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@3cdc904a@b@Pool thread stack traces:@b@    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]@b@        java.net.SocketInputStream.socketRead0(Native Method)@b@        java.net.SocketInputStream.read(SocketInputStream.java:129)@b@        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)@b@        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)@b@        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)@b@        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3014)@b@        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:592)@b@        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1078)@b@        com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2397)@b@        com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)@b@        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)@b@        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)@b@        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)@b@        sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)@b@        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)@b@        java.lang.reflect.Constructor.newInstance(Constructor.java:513)@b@        com.mysql.jdbc.Util.handleNewInstance(Util.java:411)@b@        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)@b@        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)@b@        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)@b@        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)@b@        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)@b@        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)@b@        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)@b@        com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)@b@        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)@b@    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]@b@        java.net.SocketInputStream.socketRead0(Native Method)@b@        java.net.SocketInputStream.read(SocketInputStream.java:129)@b@        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)@b@        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)@b@        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)@b@        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3014)@b@        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:592)@b@        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1078)@b@        com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2397)@b@        com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)@b@        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)@b@        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)@b@        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)@b@        sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)@b@        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)@b@        java.lang.reflect.Constructor.newInstance(Constructor.java:513)@b@        com.mysql.jdbc.Util.handleNewInstance(Util.java:411)@b@        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)@b@        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)@b@        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)@b@        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)@b@        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)@b@        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)@b@        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)@b@        com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)@b@        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)@b@    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]@b@        java.net.SocketInputStream.socketRead0(Native Method)@b@        java.net.SocketInputStream.read(SocketInputStream.java:129)@b@        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)@b@        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)@b@        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)@b@        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3014)@b@        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:592)@b@        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1078)@b@        com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2397)@b@        com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)@b@        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)@b@        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)@b@        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)@b@        sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)@b@        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)@b@        java.lang.reflect.Constructor.newInstance(Constructor.java:513)@b@        com.mysql.jdbc.Util.handleNewInstance(Util.java:411)@b@        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)@b@        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)@b@        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)@b@        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)@b@        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)@b@        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)@b@        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)@b@        com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)@b@        com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)@b@        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)@b@@b@@b@[Portal] @b@2015-10-13 21:06:22@b@[WARN]-[Thread: com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1]-[com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run()]: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6dc8f3cd -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: @b@java.sql.SQLException: null,  message from server: "Host '43.254.226.72' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"@b@    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)@b@    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)@b@    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)@b@    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1104)@b@    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2397)@b@    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)@b@    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)@b@    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)@b@    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)@b@    at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)@b@    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)@b@    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)@b@    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)@b@    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)@b@    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)@b@    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)@b@    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)@b@    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)@b@    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)@b@    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)@b@    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)@b@    at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)@b@    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)@b@[Portal] @b@2015-10-13 21:06:22

二、解决步骤

a. 直接重启mysql服务可以立马解决问题

b. 上面是治标不治本方法,需要提高max_connection_errors数量,具体如下

① 进入Mysql数据库查看max_connection_errors: show variables like '%max_connection_errors%';

② 修改max_connection_errors的数量为1000: set global max_connect_errors = 1000;

③ 查看是否修改成功:show variables like '%max_connection_errors%';

<<推荐下载>>
  • (1) 阿里巴巴Java开发手册8种不同版本
  • (2) Web前端开发视频教程
  • (3) 30+明星讲师PPT课件分享一线大厂架构实战经验
  • (4) java开发_架构篇_视频资源分享_v2208
  • (5) java开发_高级篇_视频资源分享_v2208
  • (6) java开发_进阶篇(中级)_视频资源分享_v2208
  • (7) java开发_入门篇_视频资源分享_v2208
  • (8) 微信小程序开发视频1+167源码+实战demo等下载
  • (9) easy-shopping电子商务java源码(附脚本和安装文档说明)下载
  • (10) java常用的72份知名实用的电子书下载
  • (11) java开发性能优化资料整理大全(8份电子文档+3份实战优化)下载
  • (12) 9个常用的算法设计资料和100以上视频课件内容下载
  • (13) vue开发必备常用手册16件下载
  • (14) 21种不同技术集群方案(es、flink、redis、nginx、zk、lvs、kafka、mysql、k8s等)参考资料下载
  • (15) 20种技术代码规范(js/java/dba/阿里/华为/oracle/mysql等)参考资料下载
  • (16) 微服务五套资料(0-1,架构设计,springcloud,nacos等)下载
  • (17) 架构师(28知识图谱+3套简历模板+6套架构实战文档等)完整资料整理下载
  • (18) 大数据18套实战基础知识+8套简历模板下载
  • (19) 并发编程全套(7套+阿里巴巴+亿级实战等)实战资料下载
  • (20) Kafka九套学习整理知识点全套(面试+笔记+代码api+命令+容备等)资料下载
  • (21) java全套9个不同方向类型的面试题(基础+核心+大厂+架构师+近万套题库等)下载
  • (22) JAVA开发常用API帮助文档大全(超52种以上技术资料,高手必备)下载
  • (23) springcloud超详细139件全套学习实战资料( 视频课件+源码demo+文档资料等)下载
  • <<热门文章>>