首页 > 其他分享 >seata 分支事务注册及分支事务回滚时序图梳理

seata 分支事务注册及分支事务回滚时序图梳理

时间:2022-12-30 17:13:35浏览次数:45  
标签:INFO 事务 15 seata 19 回滚 192.168 4.58 分支

1.业务时序图

集成的seata版本为1.5.2。

如图所示,创建三个微服务注册分支事务,整个流程中有四次DB操作,在最后执行异常抛出,用于演示分支事务注册及回滚时序。

 

 2.各服务日志

po出各服务日志,可参考进行自行梳理:

2.1 seata-server

15:19:40.070  INFO --- [     batchLoggerPrint_1_1] i.s.c.r.p.server.BatchLogHandler         : timeout=600000,transactionName=pay(com.boss.fundpay.entity.dto.PayInfoDto),clientIp:192.168.4.58,vgroup:fundpay-group
15:19:40.072  INFO --- [verHandlerThread_1_20_500] i.s.s.coordinator.DefaultCoordinator     : Begin new global transaction applicationId: fundpay-service,transactionServiceGroup: fundpay-group, transactionName: pay(com.boss.fundpay.entity.dto.PayInfoDto),timeout:600000,xid:192.168.4.58:8091:6890851274190960121
15:19:41.170  INFO --- [     batchLoggerPrint_1_1] i.s.c.r.p.server.BatchLogHandler         : SeataMergeMessage xid=192.168.4.58:8091:6890851274190960121,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,lockKey=SEATA_PAY_LOG:37fb734d27be481b8a1523df77acd978
,clientIp:192.168.4.58,vgroup:fundpay-group
15:19:41.174  INFO --- [verHandlerThread_1_13_500] i.seata.server.coordinator.AbstractCore  : Register branch successfully, xid = 192.168.4.58:8091:6890851274190960121, branchId = 6890851274190960124, resourceId = jdbc:oracle:thin:@XXX/YYY/ZZZ ,lockKeys = SEATA_PAY_LOG:37fb734d27be481b8a1523df77acd978
15:19:41.254  INFO --- [     batchLoggerPrint_1_1] i.s.c.r.p.server.BatchLogHandler         : SeataMergeMessage xid=192.168.4.58:8091:6890851274190960121,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,lockKey=SEATA_WORKFLOW_RECORD:7781cfe63d274c7ebf4ee3758a370f6a
,clientIp:192.168.4.58,vgroup:workflow-group
15:19:41.257  INFO --- [verHandlerThread_1_36_500] i.seata.server.coordinator.AbstractCore  : Register branch successfully, xid = 192.168.4.58:8091:6890851274190960121, branchId = 6890851274190960126, resourceId = jdbc:oracle:thin:@XXX/YYY/ZZZ ,lockKeys = SEATA_WORKFLOW_RECORD:7781cfe63d274c7ebf4ee3758a370f6a
15:19:41.343  INFO --- [     batchLoggerPrint_1_1] i.s.c.r.p.server.BatchLogHandler         : SeataMergeMessage xid=192.168.4.58:8091:6890851274190960121,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,lockKey=SEATA_BILL_INFO:ac43595c297a4a1c888522e6def1ce80
,clientIp:192.168.4.58,vgroup:account-group
15:19:41.345  INFO --- [verHandlerThread_1_35_500] i.seata.server.coordinator.AbstractCore  : Register branch successfully, xid = 192.168.4.58:8091:6890851274190960121, branchId = 6890851274190960128, resourceId = jdbc:oracle:thin:@XXX/YYY/ZZZ ,lockKeys = SEATA_BILL_INFO:ac43595c297a4a1c888522e6def1ce80
15:19:41.409  INFO --- [     batchLoggerPrint_1_1] i.s.c.r.p.server.BatchLogHandler         : SeataMergeMessage xid=192.168.4.58:8091:6890851274190960121,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,lockKey=SEATA_MERCHANT_BALANCE_RECORD:07895f7a631d44c79a74dae870089300
,clientIp:192.168.4.58,vgroup:fundpay-group
15:19:41.411  INFO --- [verHandlerThread_1_25_500] i.seata.server.coordinator.AbstractCore  : Register branch successfully, xid = 192.168.4.58:8091:6890851274190960121, branchId = 6890851274190960130, resourceId = jdbc:oracle:thin:@XXX/YYY/ZZZ ,lockKeys = SEATA_MERCHANT_BALANCE_RECORD:07895f7a631d44c79a74dae870089300
15:19:41.418  INFO --- [     batchLoggerPrint_1_1] i.s.c.r.p.server.BatchLogHandler         : xid=192.168.4.58:8091:6890851274190960121,extraData=null,clientIp:192.168.4.58,vgroup:fundpay-group
15:19:41.452  INFO --- [verHandlerThread_1_31_500] io.seata.server.coordinator.DefaultCore  : Rollback branch transaction successfully, xid = 192.168.4.58:8091:6890851274190960121 branchId = 6890851274190960130
15:19:41.472  INFO --- [verHandlerThread_1_31_500] io.seata.server.coordinator.DefaultCore  : Rollback branch transaction successfully, xid = 192.168.4.58:8091:6890851274190960121 branchId = 6890851274190960128
15:19:41.493  INFO --- [verHandlerThread_1_31_500] io.seata.server.coordinator.DefaultCore  : Rollback branch transaction successfully, xid = 192.168.4.58:8091:6890851274190960121 branchId = 6890851274190960126
15:19:41.523  INFO --- [verHandlerThread_1_31_500] io.seata.server.coordinator.DefaultCore  : Rollback branch transaction successfully, xid = 192.168.4.58:8091:6890851274190960121 branchId = 6890851274190960124
15:19:41.523  INFO --- [verHandlerThread_1_31_500] io.seata.server.coordinator.DefaultCore  : Rollback global transaction successfully, xid = 192.168.4.58:8091:6890851274190960121.
15:21:50.752  INFO --- [     RetryRollbacking_1_1] io.seata.server.coordinator.DefaultCore  : Rollback global transaction successfully, xid = 192.168.4.58:8091:6890851274190960121.

2.2 fundpay

15:19:40.073 | http-nio-9011-exec-375raceId | INFO  | 45416 | http-nio-9011-exec-375 | io.seata.tm.api.DefaultGlobalTransaction.begin(DefaultGlobalTransaction.java:118) : Begin new global transaction [192.168.4.58:8091:6890851274190960121]
insert into SEATA_PAY_LOG(bgt_id,order_no,pay_type,pay_time,total_amount,merchant_id) values(?,?,?,?,?,?)
15:19:41.353 | http-nio-9011-exec-375raceId | INFO  | 45416 | http-nio-9011-exec-375 | com.boss.fundpay.dao.Impl.MerchantBalanceRecordDaoImpl.updateBalanceRecord(MerchantBalanceRecordDaoImpl.java:54) : =======更新账户余额=========,sql is UPDATE SEATA_MERCHANT_BALANCE_RECORD SET bgt_id='07895f7a631d44c79a74dae870089300',order_no='1234567899988774560',pay_type='1',pay_time='15:19:40',total_amount='5000',merchant_id='MD122356745423350',merchant_name='小赢理财2568',total_balance='1020000' WHERE BGT_ID = '07895f7a631d44c79a74dae870089300'
15:19:41.421 | rpcDispatch_RMROLE_1_5_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_5_32 | io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.process(RmBranchRollbackProcessor.java:56) : rm handle branch rollback process:xid=192.168.4.58:8091:6890851274190960121,branchId=6890851274190960130,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,applicationData=null
15:19:41.422 | rpcDispatch_RMROLE_1_5_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_5_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:123) : Branch Rollbacking: 192.168.4.58:8091:6890851274190960121 6890851274190960130 jdbc:oracle:thin:@XXX/YYY/ZZZ
15:19:41.450 | rpcDispatch_RMROLE_1_5_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_5_32 | io.seata.rm.datasource.undo.AbstractUndoLogManager.undo(AbstractUndoLogManager.java:336) : xid 192.168.4.58:8091:6890851274190960121 branch 6890851274190960130, undo_log deleted with GlobalFinished
15:19:41.450 | rpcDispatch_RMROLE_1_5_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_5_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:131) : Branch Rollbacked result: PhaseTwo_Rollbacked
15:19:41.494 | rpcDispatch_RMROLE_1_12_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_12_32 | io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.process(RmBranchRollbackProcessor.java:56) : rm handle branch rollback process:xid=192.168.4.58:8091:6890851274190960121,branchId=6890851274190960124,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,applicationData={"skipCheckLock":true}
15:19:41.494 | rpcDispatch_RMROLE_1_12_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_12_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:123) : Branch Rollbacking: 192.168.4.58:8091:6890851274190960121 6890851274190960124 jdbc:oracle:thin:@XXX/YYY/ZZZ
15:19:41.521 | rpcDispatch_RMROLE_1_12_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_12_32 | io.seata.rm.datasource.undo.AbstractUndoLogManager.undo(AbstractUndoLogManager.java:336) : xid 192.168.4.58:8091:6890851274190960121 branch 6890851274190960124, undo_log deleted with GlobalFinished
15:19:41.522 | rpcDispatch_RMROLE_1_12_32raceId | INFO  | 45416 | rpcDispatch_RMROLE_1_12_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:131) : Branch Rollbacked result: PhaseTwo_Rollbacked
15:19:41.524 | http-nio-9011-exec-375raceId | INFO  | 45416 | http-nio-9011-exec-375 | io.seata.tm.api.DefaultGlobalTransaction.suspend(DefaultGlobalTransaction.java:199) : Suspending current transaction, xid = 192.168.4.58:8091:6890851274190960121
15:19:41.524 | http-nio-9011-exec-375raceId | INFO  | 45416 | http-nio-9011-exec-375 | io.seata.tm.api.DefaultGlobalTransaction.rollback(DefaultGlobalTransaction.java:189) : [192.168.4.58:8091:6890851274190960121] rollback status: Rollbacked
java.lang.ArithmeticException: / by zero
    at com.boss.fundpay.service.impl.PayServiceImpl.pay(PayServiceImpl.java:98)

2.3 workflow

15:19:41.192 | http-nio-9013-exec-331raceId | INFO  | 43480 | http-nio-9013-exec-331 | com.boss.workflow.service.impl.WorkflowServiceImpl.riskAudit(WorkflowServiceImpl.java:30) : fund-pay申请调用
15:19:41.196 | http-nio-9013-exec-331raceId | INFO  | 43480 | http-nio-9013-exec-331 | com.boss.workflow.dao.Impl.WorkflowDaoImpl.insertRiskAudit(WorkflowDaoImpl.java:32) : =========插入SEATA_WORKFLOW_RECORD表数据,{"bgt_id":"7781cfe63d274c7ebf4ee3758a370f6a","order_no":"1234567899988774560","merchant_id":"MD122356745423350","platform":"同盾","risk_score":"100","result_code":"1","result_msg":"通过","opinion":"商户无风险"} ============
insert into SEATA_WORKFLOW_RECORD(bgt_id,merchant_id,platform,result_code,result_msg,opinion,order_no) values(?,?,?,?,?,?,?)
15:19:41.266 | http-nio-9013-exec-331raceId | WARN  | 43480 | http-nio-9013-exec-331 | com.alibaba.cloud.seata.web.SeataHandlerInterceptor.afterCompletion(SeataHandlerInterceptor.java:85) : xid in change during RPC from 192.168.4.58:8091:6890851274190960121 to null
15:19:41.474 | rpcDispatch_RMROLE_1_2_32raceId | INFO  | 43480 | rpcDispatch_RMROLE_1_2_32 | io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.process(RmBranchRollbackProcessor.java:56) : rm handle branch rollback process:xid=192.168.4.58:8091:6890851274190960121,branchId=6890851274190960126,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,applicationData={"autoCommit":false}
15:19:41.474 | rpcDispatch_RMROLE_1_2_32raceId | INFO  | 43480 | rpcDispatch_RMROLE_1_2_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:123) : Branch Rollbacking: 192.168.4.58:8091:6890851274190960121 6890851274190960126 jdbc:oracle:thin:@XXX/YYY/ZZZ
15:19:41.491 | rpcDispatch_RMROLE_1_2_32raceId | INFO  | 43480 | rpcDispatch_RMROLE_1_2_32 | io.seata.rm.datasource.undo.AbstractUndoLogManager.undo(AbstractUndoLogManager.java:336) : xid 192.168.4.58:8091:6890851274190960121 branch 6890851274190960126, undo_log deleted with GlobalFinished
15:19:41.491 | rpcDispatch_RMROLE_1_2_32raceId | INFO  | 43480 | rpcDispatch_RMROLE_1_2_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:131) : Branch Rollbacked result: PhaseTwo_Rollbacked

2.4 account

15:19:41.281 | http-nio-9012-exec-246raceId | INFO  | 42908 | http-nio-9012-exec-246 | com.boss.account.service.impl.AccountServiceImpl.increaseBill(AccountServiceImpl.java:26) : ========================fund-pay申请调用account===================
15:19:41.282 | http-nio-9012-exec-246raceId | INFO  | 42908 | http-nio-9012-exec-246 | com.boss.account.dao.Impl.AccountDaoImpl.increaseBill(AccountDaoImpl.java:38) : =======记账商户余额=========,sql is UPDATE SEATA_BILL_INFO SET order_no='1234567899988774560',account_amount='1020000',merchant_id='MD122356745423350' WHERE MERCHANT_ID = 'MD122356745423350'
15:19:41.352 | http-nio-9012-exec-246raceId | WARN  | 42908 | http-nio-9012-exec-246 | com.alibaba.cloud.seata.web.SeataHandlerInterceptor.afterCompletion(SeataHandlerInterceptor.java:85) : xid in change during RPC from 192.168.4.58:8091:6890851274190960121 to null
15:19:41.453 | rpcDispatch_RMROLE_1_17_32raceId | INFO  | 42908 | rpcDispatch_RMROLE_1_17_32 | io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.process(RmBranchRollbackProcessor.java:56) : rm handle branch rollback process:xid=192.168.4.58:8091:6890851274190960121,branchId=6890851274190960128,branchType=AT,resourceId=jdbc:oracle:thin:@XXX/YYY/ZZZ,applicationData={"autoCommit":false}
15:19:41.453 | rpcDispatch_RMROLE_1_17_32raceId | INFO  | 42908 | rpcDispatch_RMROLE_1_17_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:123) : Branch Rollbacking: 192.168.4.58:8091:6890851274190960121 6890851274190960128 jdbc:oracle:thin:@XXX/YYY/ZZZ
15:19:41.470 | rpcDispatch_RMROLE_1_17_32raceId | INFO  | 42908 | rpcDispatch_RMROLE_1_17_32 | io.seata.rm.datasource.undo.AbstractUndoLogManager.undo(AbstractUndoLogManager.java:336) : xid 192.168.4.58:8091:6890851274190960121 branch 6890851274190960128, undo_log deleted with GlobalFinished
15:19:41.471 | rpcDispatch_RMROLE_1_17_32raceId | INFO  | 42908 | rpcDispatch_RMROLE_1_17_32 | io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:131) : Branch Rollbacked result: PhaseTwo_Rollbacked

3. 执行时序图

 

标签:INFO,事务,15,seata,19,回滚,192.168,4.58,分支
From: https://www.cnblogs.com/zjfjava/p/17015317.html

相关文章

  • IDEA切换git分支时如何使用git stash
    切换分支弹出提示:ForceCheckout/Smartcheckout打开帮助文档原文如下:翻译大意如下:多任务(就是多分支)开发时,经常需要在分支之间切换跳转来提交无关联的修改在idea上......
  • MySQL-(InnoDB)事务和锁
    在事务并行处理背景下,不同的事务之间因数据共享的状态变化,存在着某种依赖/隔离影响。即事务隔离级别。事务隔离级别,官网的解释在这里。InnoDB提供SQL:1992标准描述的所......
  • git分支的一些处理情况记录
    一、开发分支(dev)上的代码更新后,要合并到master分支gitcheckoutdev#切换到dev分支gitpull#将远程更新的代码同步到本地gitcheckoutmaster#切......
  • Spring声明式事务配置管理方法
    事务配置首先在/WEB-INF/applicationContext.xml添加以下内容:<!--配置事务管理器--><beanid="transactionManager"class="org.springframework.orm.hibernate3.Hibernat......
  • oracle数据库表数据回滚到某一时间
    1、查询某一时间点该表的数据select*from表asoftimestampto_timestamp('2020-07-0212:11:11','yyyy-mm-ddhh24:mi:ss');2、对表进行行迁移altertable表enable......
  • 分布式三大热门"IP"之分布式事务随笔
    理论最近在看一些分布式方面的书籍.关于分布式事务这个话题自己也是有一些感受和理解.将他写下来.供自己以后回首的时候,方便重拾记忆.分布式中有三个理论ACID/CAP......
  • Spring 多数据源事务配置问题
    在SpringSide3中,白衣提供的预先配置好的环境非常有利于用户进行快速开发,但是同时也会为扩展带来一些困难。最直接的例子就是关于在项目中使用多个数据源的问题,似乎很难搞......
  • 基于Seata探寻分布式事务的实现方案
    作者:京东物流技术与数据智能部张硕1背景知识随着业务的快速发展、业务复杂度越来越高,几乎每个公司的系统都会从单体走向分布式,特别是转向微服务架构。随之而来就必然遇......
  • spring事务理解
    分布式事务中是否可以有加锁解锁的逻辑?可以,但是不规范的话会有线程安全问题。下方逻辑:在解锁后,并发线程会再执行一遍锁里的逻辑,因为此时事务未提交,在隔离级别不是readun......
  • Spring学习笔记 - 第三章 - AOP与Spring事务
    原文地址:Spring学习笔记-第三章-AOP与Spring事务Spring学习笔记全系列传送门:Spring学习笔记-第一章-IoC(控制反转)、IoC容器、Bean的实例化与生命周期、DI(依......