今天发现save task的时候经常后台会报这个错,而且有的时候还会卡住等20几分钟才执行完。

2019-11-12 15:08:29.410 http-nio-9080-exec-6 ERROR org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:182) - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.TransientDataAccessResourceException:
### Error updating database. Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: delete from t_taskcomment where task_code = ?
### Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server
; SQL []; Could not retrieve transaction read-only status from server; nested exception is java.sql.SQLException: Could not retrieve transaction read-only status from server] with root cause java.sql.SQLException: ResultSet is from UPDATE. No Data.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:6302) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3551) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3524) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.PreparedStatement.checkReadOnlySafeStatement(PreparedStatement.java:1158) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1178) ~[mysql-connector-java-5.1.47.jar!/:5.1.47]
at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493) ~[druid-1.1.0.jar!/:1.1.0]
at sun.reflect.GeneratedMethodAccessor249.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.4.6.jar!/:3.4.6]
at com.sun.proxy.$Proxy210.execute(Unknown Source) ~[?:?]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46) ~[mybatis-3.4.6.jar!/:3.4.6]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.4.6.jar!/:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.4.6.jar!/:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.4.6.jar!/:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.4.6.jar!/:3.4.6]
at sun.reflect.GeneratedMethodAccessor293.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) ~[mybatis-3.4.6.jar!/:3.4.6]
at com.sun.proxy.$Proxy208.update(Unknown Source) ~[?:?]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198) ~[mybatis-3.4.6.jar!/:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:213) ~[mybatis-3.4.6.jar!/:3.4.6]
at sun.reflect.GeneratedMethodAccessor481.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.2.jar!/:1.3.2]
at com.sun.proxy.$Proxy112.delete(Unknown Source) ~[?:?]
at org.mybatis.spring.SqlSessionTemplate.delete(SqlSessionTemplate.java:310) ~[mybatis-spring-1.3.2.jar!/:1.3.2]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) ~[mybatis-3.4.6.jar!/:3.4.6]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.6.jar!/:3.4.6]
at com.sun.proxy.$Proxy159.deleteBytaskcode(Unknown Source) ~[?:?]
at com.hp.nova.service.impl.instance.InstanceServiceImpl.AddInstance(InstanceServiceImpl.java:373) ~[classes!/:0.0.1-SNAPSHOT]

后来网上查了很多解决方法,进行了如下配置:

mysql进行如下配置重启

[mysql]
default-character-set=utf8
[mysqld]
skip-name-resolve
interactive_timeout = 120

wait_timeout = 3600
max_allowed_packet = 64M
log-bin=mysql-bin
server-id=153

character-set-server=utf8
innodb_buffer_pool_size = 1024M
innodb_lock_wait_timeout = 500
transaction_isolation = READ-COMMITTED

log-slave-updates
auto-increment-increment = 2
auto-increment-offset = 2

default-time_zone = '+8:00'

mycat添加如下配置重启

<system>
<property name="sqlExecuteTimeout">3000</property>

task和plan的微服务的yml添加如下配置重启:

ribbon:
    ReadTimeout: 1200000
    ConnectTimeout: 1200000

进行了上述操作还是问题没有解决,后来有的网上又说mysql的驱动包有问题,我把task微服务的mysql驱动从5.1.47分别换成了mysql 5.1.27  和 mysql 8.0.18 还是没有用

最后发现是task save的时候可能事务有问题,有可能是mycat问题也有可能是mysql的问题,反正我都改成了如下配置,然后重启后台就好了,暂时没有发现read-only错误了,后续继续观察。

@Transactional(propagation=Propagation.NOT_SUPPORTED)

Could not retrieve transaction read-only status from server问题排查的更多相关文章

  1. MySQL案例04:Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server

    今天同事发现程序日志有异常抛出,询问原因,进过排查发现与java的连接参数有关系,具体处理过程如下: 一.错误信息 "message": "\n### Error upd ...

  2. 【异常】java.sql.SQLException: Could not retrieve transaction read-only status from server Query

    1 详细异常 java.sql.SQLException: Could not retrieve transaction read-only status , ], [ChargingOrderRea ...

  3. java.sql.SQLException: Could not retrieve transaction read-only status from server 问题解决

    网上有2种主要说法 第一种 问题描述: java代码在开始事务后,先做了一个查询,再insert,此时会报:          java.sql.SQLException: could not ret ...

  4. 【FAQ】【JSP】HTTP Status 500 - Summary(问题排查时候应该仔细分析所有的错误打印说明)

    Question 1.HTTP Status 500 - Unable to compile class for JSP:'***' cannot be resolved to a type 原因分析 ...

  5. Cause: java.sql.SQLException: Could not retrieve transation read-only status server

    背景 最近在部署一套完整的项目,部署过程中遇到很多的问题,在来总结一些如标题的这个错误! 环境说明: 使用分布式数据库,使用的是mysql! ### Cause: java.sql.SQLExcept ...

  6. spring Transaction Management --官方

    原文链接:http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html 12.  ...

  7. flume-sink报错 java.lang.IllegalStateException: close() called when transaction is OPEN - you must either commit or rollback first

    1. 确认代码无误(根据情况修改,表示若获得不了数据不会自动commit或者rollback): Event event = channel.take(); if (event == null) { ...

  8. SAP CRM One order里user status和system status的mapping逻辑

    Below example show: How the mapping relationship between User status and System status maintained in ...

  9. WCF分布式开发步步为赢(12):WCF事务机制(Transaction)和分布式事务编程

    今天我们继续学习WCF分布式开发步步为赢系列的12节:WCF事务机制(Transaction)和分布式事务编程.众所周知,应用系统开发过程中,事务是一个重要的概念.它是保证数据与服务可靠性的重要机制. ...

随机推荐

  1. angular中的动态路由

    1.配置动态路由 const routes: Routes = [ {path: 'home', component: HomeComponent}, {path: 'news', component ...

  2. Carve ifc failed

    Detected IFC version: IFC2X3 Warning: Sweeper::createTriangulated3DFace, carve::triangulate::incorpo ...

  3. jq删除标签

    <script>$(function(){ $("div").remove()})</script>

  4. python中简化的验证码功能

    验证码一般用来验证登陆.交易等行为,减少对端为机器操作的概率,python中可以使用random模块,char()内置函数来实现一个简单的验证码功能. import random def veri_c ...

  5. LeetCode_190. Reverse Bits

    190. Reverse Bits Easy Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 000000101 ...

  6. 【设计】PC Web端框架组件

    https://uedart.com/demo/templatesWebKit/index.html#g=1&p=%E4%BD%9C%E5%93%81%E9%A6%96%E9%A1%B5 移动 ...

  7. mysql为字段添加或删除自增属性

    删除自增属性: ALTER TABLE `members` CHANGE uid uid INT(10) UNSIGNED NOT NULL ; 添加自增属性: ALTER TABLE `member ...

  8. laravel原生sql

    转自:https://www.cnblogs.com/zouzhe0/p/6307077.html DB::insert(, ']); $user = DB::]); //我们还 可以看到在执行查询的 ...

  9. PHP爬虫最全总结2-phpQuery,PHPcrawer,snoopy框架中文介绍

    第一篇文章介绍了使用原生的PHP和PHP的扩展库实现了爬虫技术.本文尝试使用PHP爬虫框架来写,首先对三种爬虫技术phpQuery,PHPcrawer, snoopy进行对比,然后分析模拟浏览器行为的 ...

  10. Fakes中Shim的2种方法

    Fakes自动生成的Shim代码,有两种可能:(目前尚不清楚生成规律) //属性型 public static FakesDelegates.Func<string, bool, string& ...