一、问题现象
因超过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%';