首页 > 数据库 >记一次节点被mysql锁定的异常处理

记一次节点被mysql锁定的异常处理

时间:2022-12-14 11:02:31浏览次数:88  
标签:java 节点 v2 mchange mysql 锁定 com BasicResourcePool

参考:https://blog.csdn.net/weixin_34293141/article/details/93057113

同事反馈公司的一个java客户端工具运行异常,后台log如下:

2022-12-08 10:52:28 WARN BasicResourcePool:223 - com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@18afde8 -- 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: java.sql.SQLException: null, message from server: "Host 'VBJVDI00378.test.com' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'" at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1095) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718) at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46) at sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125) at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

log重点:

2022-12-08 10:52:28 WARN BasicResourcePool:223 - com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@18afde8 -- 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:
java.sql.SQLException: null, message from server: "Host 'VBJVDI00378.test.com' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

根据重点log,可以找到以下几点:
1)问题:
Host 'VBJVDI00378.test.com' is blocked because of many connection errors
同一个ip在短时间连接MySQL服务失败次数超过max_connection_errors参数设定值(默认10),MySQL则认为是数据库出错,并且阻止了站点的链接。
2)解决方法一:
unblock with 'mysqladmin flush-hosts
终端中执行mysqladmin -uroot -p -h localhost flush-hosts
或者连接数据库后执行flush hosts
mysql>flush hosts
3)解决方法二:
进入数据库将max_connection_errors参数调高,或者修改my.cnf(需要重启MySQL)。

mysql>show variables like '%max_connection_errors%';
mysql>set global max_connect_errors = 1000;
mysql>show variables like '%max_connection_errors%';

注意:配置有master/slave主从数据库的要把主库和从库都修改一遍的。

标签:java,节点,v2,mchange,mysql,锁定,com,BasicResourcePool
From: https://www.cnblogs.com/21summer/p/16977662.html

相关文章

  • 重启mysql的时候,mysql日志也会抛错错误
    修改mysql配置文件,移动mysql数据存储位置修改。重启mysql的时候,mysql日志也会抛错错误2021-11-27T00:34:43.403963Z0[ERROR]Failedtoopenlog(file'/logs/mysq......
  • linux中安装mysql
    1.安装Linux系统中自带的MySQL安装包在现在常用的发行版本里都集中了MySQL安装包CentOS系统中的YUM中包含了MySQL安装包,版本是MySQL5,rpm软件包的名称是mysql-server......
  • Mysql一个表编码的坑,mark一下
    问题:一个sql执行很慢,5分钟左右,关键是最大的表是5万出头,另一张表不到5000原因:是两个表的字符集不同,导致匹配时,没有匹配到解决办法:将两个表的字符集改成一样具体的命令:ALTERT......
  • mysql 将字段复制到另一个字段(数据运维)
    1.将同一个表中的一个字段的值复制给另一个字段UPDATEt_userSETsigned_time=create_time  create_time  是源数据,signed_time是目标数据,之前是空的2.将同一个......
  • 链表--删除链表的中间节点
    题目:给定链表的头节点,实现删除链表的中间节点的函数例如:不删除任何节点1->2删除节点21->2->3删除节点21->2->3->4删除节点21->2->3->4->5删除节点31->2->3->4->5......
  • 2:数据库的基本操作-MySQL
    (目录)2.1数据库的显示讲解information_schema:信息图式,存储服务器管理数据库的信息mysql:存放系统信息,用户名密码等performance_schema:性能图式sys:系统文件showdat......
  • MySQL
    MySQLALTER命令当我们需要修改数据表名或者修改数据表字段时,就需要使用到MySQLALTER命令。开始本章教程前让我们先创建一张表,表名为:testalter_tbl。root@host#mysql-u......
  • MySQL事务必知必会
    事务必知必会事务由一组数据操纵语句(DML)组成,这组语句要么全部成功,要么全部失败事务操作开启事务starttransaction;设置保存点savepoint保存点名;回退到某个保存......
  • mysql 可视化操作工具 ide
    一款好的数据库可视化工具可以很好的加快我们简化我们对数据库的操作,我这里总结了常用的mysql可视化操作工具;1.navicat(收费)navicat是一套快速、可靠的数据库管理工具,nav......
  • 笔记本自带键盘锁定
    锁定与解锁均需要重启才生效win键->搜索cmd,打开复制锁定scconfigi8042prtstart=disabled解锁scconfigi8042prtstart=demand粘贴->回车重启即可生效......