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