记一次Could-not-retrieve-transation-readonly-status-server异常

8次阅读

共计 1010 个字符,预计需要花费 3 分钟才能阅读完成。

简述:
技术,spring+mysql….
新项目上线碰到一个问题,具体现象为执行一个方法时报异常,异常信息如下:

2019-08-20 09:46:08.917[ERROR][Log4jFilter.java:152][DubboServerHandler-192.168.12.156:28104-thread-207] {conn-10670, pstmt-21062} execute error. delete from Dpgd where shco = ?
java.sql.SQLException: Could not retrieve transation read-only status server
    ....
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 7,603 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
    ...
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1038)

最开始只看到 Could not retrieve transation read-only status server 没看到下面的 Communications link failure,以为是在代码中手动设置事务状态为只读或者事务回滚,后来查代码也没发现。
当看到 Communications link failure 意识到连接异常,但与当前方法连接同一个库的其他方法可以执行成功,所以数据库服务也是正常的。

最终发现原因:排查的方法中有其他操作发送 http 请求,稍微有点耗时,但整个方法一分钟之类肯定能处理完。

最终解决办法:

show global variables like '%timeout%';
SET GLOBAL wait_timeout=86400;

此处的单位应该是秒。
当前处理的默认值是 5
设置 86400 可能有点极端

其他客户都设置了,就这个可能测试环境,配置的时候忘记改参数了。

正文完
 0