apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.33k stars 8.78k forks source link

RmTransactionException: Response[ TransactionException[Could not found global transaction xid = 192.168.10.6:8091:2038906488] ] #2460

Open zhuenjun opened 4 years ago

zhuenjun commented 4 years ago

2020-03-26 15:26:24.293 ERROR 7969 --- [io-18081-exec-1] i.s.r.d.exec.AbstractDMLBaseExecutor : execute executeAutoCommitTrue error:io.seata.core.exception.RmTransactionException: Response[ TransactionException[Could not found global transaction xid = 192.168.10.6:8091:2038906488] ]

java.sql.SQLException: io.seata.core.exception.RmTransactionException: Response[ TransactionException[Could not found global transaction xid = 192.168.10.6:8091:2038906488] ] at io.seata.rm.datasource.ConnectionProxy.recognizeLockKeyConflictException(ConnectionProxy.java:151) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:213) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.ConnectionProxy.doCommit(ConnectionProxy.java:190) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.ConnectionProxy.lambda$commit$0(ConnectionProxy.java:178) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.execute(ConnectionProxy.java:283) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.ConnectionProxy.commit(ConnectionProxy.java:177) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.lambda$executeAutoCommitTrue$0(AbstractDMLBaseExecutor.java:92) [seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.ConnectionProxy$LockRetryPolicy.doRetryOnLockConflict(ConnectionProxy.java:293) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor$LockRetryPolicy.execute(AbstractDMLBaseExecutor.java:135) ~[seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitTrue(AbstractDMLBaseExecutor.java:90) [seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:58) [seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:95) [seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:101) [seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:47) [seata-all-1.0.0.jar:1.0.0] at io.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:54) [seata-all-1.0.0.jar:1.0.0] at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) [mybatis-3.5.3.jar:3.5.3] at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) [mybatis-3.5.3.jar:3.5.3] at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doUpdate(MybatisSimpleExecutor.java:54) [mybatis-plus-core-3.3.1.tmp.jar:3.3.1.tmp] at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) [mybatis-3.5.3.jar:3.5.3] at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.update(MybatisCachingExecutor.java:83) [mybatis-plus-core-3.3.1.tmp.jar:3.3.1.tmp] at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) [mybatis-3.5.3.jar:3.5.3] at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184) [mybatis-3.5.3.jar:3.5.3] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) [mybatis-spring-2.0.3.jar:2.0.3] at com.sun.proxy.$Proxy77.insert(Unknown Source) [na:na] at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271) [mybatis-spring-2.0.3.jar:2.0.3] at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:60) [mybatis-plus-core-3.3.1.tmp.jar:3.3.1.tmp] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:96) [mybatis-plus-core-3.3.1.tmp.jar:3.3.1.tmp] at com.sun.proxy.$Proxy80.insert(Unknown Source) [na:na]

zhuenjun commented 4 years ago

在第一次启动项目时,第一次请求总是出现这样的异常

zhuenjun commented 4 years ago

之后请求都是成功的

slievrly commented 4 years ago

@zhuenjun please make sure whether the service is timeout.

hermitcai commented 4 years ago

this case i Often encountered

zgz757183190 commented 4 years ago

@zhuenjun please make sure whether the service is timeout.

这个 xid 是不是有一个超时的机制啊? 超时时间时多少呢?

(Response[ TransactionException[Could not found global transaction xid = 47.112.208.130:8091:2012852579, may be has finished.] ])

linkai0001 commented 4 years ago

这两天刚接触,也出现了类似的问题。

  1. TC单机 我是基于 feign 调用,单机的话一般和 feign 设定的连接和读取超时有关, feign.client.config.被调用服务注册的服务名.connect-timeout=6000 feign.client.config.被调用服务注册的服务名.read-timeout=6000 注意: A调用B,B的方法中设置休眠2S,问题是必现的。
  2. TC集群 集群 TC 使用 db或其他中间件存储事务日志,一定得共享事务日志数据

再有 @GlobalTransactional 默认的timeoutMills 为 60000ms , 除非处理的功能需要较长时间,否则这个应该也不至于影响

jsbxyyx commented 4 years ago

@zhuenjun 和seata没有关系,第一次超时是因为spring cloud内部有很多需要初始化导致的,你抛开seata,你可以看看你第一次调用执行的时间,肯定也会超过60s。

lgl48128244 commented 4 years ago

明显是你微服务出现超时调用,设置下超时时间就可以了。

feign:
  httpclient:
    connection-timeout: 60000
    connection-timer-repeat: 3000

ribbon:
  ConnectTimeout: 60000 # 设置连接超时时间 default 2000
  ReadTimeout: 60000   # 设置读取超时时间  default 5000
  OkToRetryOnAllOperations: true # 对所有操作请求都进行重试  default false
  MaxAutoRetriesNextServer: 20    # 切换实例的重试次数  default 1
  MaxAutoRetries: 10     # 对当前实例的重试次数 default 0
dongfsgf commented 3 years ago

在第一次启动项目时,第一次请求总是出现这样的异常

我也是这样的,你解决了吗

dongfsgf commented 3 years ago

明显是你微服务出现超时调用,设置下超时时间就可以了。

feign:
  httpclient:
    connection-timeout: 60000
    connection-timer-repeat: 3000

ribbon:
  ConnectTimeout: 60000 # 设置连接超时时间 default 2000
  ReadTimeout: 60000   # 设置读取超时时间  default 5000
  OkToRetryOnAllOperations: true # 对所有操作请求都进行重试  default false
  MaxAutoRetriesNextServer: 20    # 切换实例的重试次数  default 1
  MaxAutoRetries: 10     # 对当前实例的重试次数 default 0

@lgl48128244 好像没用

zh519680053 commented 1 year ago

查看一下各自服务器时间与数据库时间是否一致