nakerny opened a new issue, #6478: URL: https://github.com/apache/incubator-seata/issues/6478
<!-- Please do not use this issue template to report security vulnerabilities but refer to our [security policy](https://github.com/seata/seata/security/policy). --> - [ ] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate. ### Ⅰ. Issue Description 在AT模式下,出现二阶段回滚失败的全局事务后,不会立即进行回滚重试,而是在大约2分钟后才会看到重试日志并且回滚成功 ### Ⅱ. Describe what happened 在经过业务分析和代码调试之后发现如下问题 1、当系统中存在大量的需要回滚的全局事务时(业务逻辑问题,大约2分钟内有600条左右),global_table表中的记录均处于Rollbacking状态(status=4),且该类型记录大约在2分钟后才会被删除,但是该类型的全局事务其实已经完成二阶段回滚 2、上述问题原因如下: a、发生业务异常进行全局事务回滚,服务端代码流程为调用 org.apache.seata.server.coordinator.DefaultCore#rollback-->org.apache.seata.server.coordinator.DefaultCore#doGlobalRollback  b、当所有分支事务回滚成功后,此处没有赋予全局事务一个最终状态。进入endRollbacked方法后,由于retryGlobal=false,也未对全局事务状态进行变更   c、因此global_table表中存在大量Rollbacking状态(status=4)的记录(实际状态应该为GlobalStatus.Rollbacked) 2、造成的影响: a、在上述情况下某个全局事务由于业务异常发生回滚,但是在某个分支事务进行二阶段回滚时发生异常造成全局事务回滚失败,且回滚失败上报seata-server服务端TC成功,数据库记录变更状态为GlobalStatus.RollbackRetrying  b、服务端进行回滚失败重试流程如下: 1)默认配置下每隔1s钟从数据库中获取状态为GlobalStatus.TimeoutRollbacking, GlobalStatus.TimeoutRollbackRetrying, GlobalStatus.RollbackRetrying, GlobalStatus.Rollbacking四种状态的记录 2)默认配置store.db.queryLimit=100,也就是说每次定时任务只能从global_table表中获取100条 3)默认配置DeadSession的时间为2分10秒钟(这也是为什么大约2分钟后Rollbacking状态记录才会被删除)  4)由于global_table表中存在大量RollBacking状态的异常记录(大于100条),每次定时任务仅能从数据库中拿取100条记录,且这100条记录没一条都会直到2分10秒后DeadSesssion状态触发后才会被删除处理,上述二阶段回滚失败的记录也会直到2分钟之后才会进行重试(该事务持有的全局事务锁和业务数据库异常记录都会对业务造成影响)  ### Ⅲ. Describe what you expected to happen 第一次全局事务回滚成功后需要一个最终状态(GlobalStatus.Rollbacked),并进行变更 现在能想到是通过计数器记录回滚分支事务的数量,全部分支事务回滚完成后变更全局事务状态,但也不是很合理  ### Ⅵ. Environment: - JDK version(e.g. `java -version`):1.8.0_341 - Seata client/server version: v2.0.0 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org