全局事务的执行日志
修改配置:
bash
logging.level.io.seata=debug
bash
TransactionPropagationInterceptor - [preHandle,44] - xid in RootContext[null] xid in HttpContext[null]
AbstractNettyRemotingClient - [sendSyncRequest,164] - offer message: timeout=60000,transactionName=scorpios-create-order
AbstractNettyRemoting - [sendAsync,220] - write message:SeataMergeMessage timeout=60000,transactionName=scorpios-create-order
, channel:[id: 0x758aa084, L:/172.16.5.39:55534 - R:/192.168.14.236:8091],active?true,writable?true,isopen?true
AbstractNettyRemoting - [processMessage,268] - io.seata.core.rpc.netty.TmNettyRemotingClient@2344121 msgId:18, body:MergeResultMessage xid=192.168.14.236:8091:6737814217289867327;extraData=;
RootContext - [bind,112] - bind 192.168.14.236:8091:6737814217289867327
DefaultGlobalTransaction - [begin,109] - Begin new global transaction [192.168.14.236:8091:6737814217289867327]
OrderServiceImpl - [create,35] - ----->开始新建订单
AbstractNettyRemotingClient - [sendSyncRequest,164] - offer message: xid=192.168.14.236:8091:6737814217289867327,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,lockKey=t_order:33
AbstractNettyRemoting - [sendAsync,220] - write message:SeataMergeMessage xid=192.168.14.236:8091:6737814217289867327,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,lockKey=t_order:33
, channel:[id: 0x4cd5c7f0, L:/172.16.5.39:55487 - R:/192.168.14.236:8091],active?true,writable?true,isopen?true
AbstractNettyRemoting - [processMessage,268] - io.seata.core.rpc.netty.RmNettyRemotingClient@3077b8c6 msgId:19, body:MergeResultMessage BranchRegisterResponse: branchId=6737814217289867328,result code =Success,getMsg =null
AbstractUndoLogManager - [flushUndoLogs,239] - Flushing UNDO LOG: {"@class":"io.seata.rm.datasource.undo.BranchUndoLog","xid":"192.168.14.236:8091:6737814217289867327","branchId":6737814217289867328,"sqlUndoLogs":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.undo.SQLUndoLog","sqlType":"INSERT","tableName":"t_order","beforeImage":{"@class":"io.seata.rm.datasource.sql.struct.TableRecords$EmptyTableRecords","tableName":"t_order","rows":["java.util.ArrayList",[]]},"afterImage":{"@class":"io.seata.rm.datasource.sql.struct.TableRecords","tableName":"t_order","rows":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Row","fields":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"id","keyType":"PRIMARY_KEY","type":-5,"value":["java.lang.Long",33]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"user_id","keyType":"NULL","type":-5,"value":["java.lang.Long",1]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"product_id","keyType":"NULL","type":-5,"value":["java.lang.Long",1]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"count","keyType":"NULL","type":4,"value":10},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"money","keyType":"NULL","type":3,"value":["java.math.BigDecimal",100]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"status","keyType":"NULL","type":4,"value":0}]]}]]}}]]}
OrderServiceImpl - [create,40] - ----->订单微服务开始调用库存,做扣减Count
OrderServiceImpl - [create,42] - ----->订单微服务开始调用库存,做扣减end
OrderServiceImpl - [create,45] - ----->订单微服务开始调用账户,做扣减Money
OrderServiceImpl - [create,47] - ----->订单微服务开始调用账户,做扣减end
OrderServiceImpl - [create,50] - ----->修改订单状态开始
AbstractNettyRemotingClient - [sendSyncRequest,164] - offer message: xid=192.168.14.236:8091:6737814217289867327,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,lockKey=t_order:33
AbstractNettyRemoting - [sendAsync,220] - write message:SeataMergeMessage xid=192.168.14.236:8091:6737814217289867327,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,lockKey=t_order:33
, channel:[id: 0x4cd5c7f0, L:/172.16.5.39:55487 - R:/192.168.14.236:8091],active?true,writable?true,isopen?true
AbstractNettyRemoting - [processMessage,268] - io.seata.core.rpc.netty.RmNettyRemotingClient@3077b8c6 msgId:21, body:MergeResultMessage BranchRegisterResponse: branchId=6737814217289867331,result code =Success,getMsg =null
AbstractUndoLogManager - [flushUndoLogs,239] - Flushing UNDO LOG: {"@class":"io.seata.rm.datasource.undo.BranchUndoLog","xid":"192.168.14.236:8091:6737814217289867327","branchId":6737814217289867331,"sqlUndoLogs":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.undo.SQLUndoLog","sqlType":"UPDATE","tableName":"t_order","beforeImage":{"@class":"io.seata.rm.datasource.sql.struct.TableRecords","tableName":"t_order","rows":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Row","fields":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"id","keyType":"PRIMARY_KEY","type":-5,"value":["java.lang.Long",33]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"status","keyType":"NULL","type":4,"value":0}]]}]]},"afterImage":{"@class":"io.seata.rm.datasource.sql.struct.TableRecords","tableName":"t_order","rows":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Row","fields":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"id","keyType":"PRIMARY_KEY","type":-5,"value":["java.lang.Long",33]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"status","keyType":"NULL","type":4,"value":1}]]}]]}}]]}
OrderServiceImpl - [create,52] - ----->修改订单状态结束
OrderServiceImpl - [create,54] - ----->下订单结束了
AbstractNettyRemotingClient - [sendSyncRequest,164] - offer message: xid=192.168.14.236:8091:6737814217289867327,extraData=null
AbstractNettyRemoting - [sendAsync,220] - write message:SeataMergeMessage xid=192.168.14.236:8091:6737814217289867327,extraData=null
, channel:[id: 0x758aa084, L:/172.16.5.39:55534 - R:/192.168.14.236:8091],active?true,writable?true,isopen?true
AbstractNettyRemoting - [processMessage,268] - io.seata.core.rpc.netty.TmNettyRemotingClient@2344121 msgId:20, body:MergeResultMessage globalStatus=Committed,ResultCode=Success,Msg=null
DefaultGlobalTransaction - [suspend,188] - Suspending current transaction, xid = 192.168.14.236:8091:6737814217289867327
RootContext - [unbind,140] - unbind 192.168.14.236:8091:6737814217289867327
DefaultGlobalTransaction - [commit,143] - [192.168.14.236:8091:6737814217289867327] commit status: Committed
库存模块日志:
bash
RootContext - [bind,112] - bind 192.168.14.236:8091:6737814217289867327
TransactionPropagationInterceptor - [preHandle,44] - xid in RootContext[192.168.14.236:8091:6737814217289867327] xid in HttpContext[192.168.14.236:8091:6737814217289867327]
StorageServiceImpl - [decrease,22] - ------->storage-service中扣减库存开始
AbstractNettyRemotingClient - [sendSyncRequest,164] - offer message: xid=192.168.14.236:8091:6737814217289867327,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,lockKey=t_storage:1
AbstractNettyRemoting - [sendAsync,220] - write message:SeataMergeMessage xid=192.168.14.236:8091:6737814217289867327,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,lockKey=t_storage:1
, channel:[id: 0x0030614b, L:/172.16.5.39:55514 - R:/192.168.14.236:8091],active?true,writable?true,isopen?true
AbstractNettyRemoting - [processMessage,268] - io.seata.core.rpc.netty.RmNettyRemotingClient@21aeb302 msgId:18, body:MergeResultMessage BranchRegisterResponse: branchId=6737814217289867329,result code =Success,getMsg =null
AbstractUndoLogManager - [flushUndoLogs,239] - Flushing UNDO LOG: {"@class":"io.seata.rm.datasource.undo.BranchUndoLog","xid":"192.168.14.236:8091:6737814217289867327","branchId":6737814217289867329,"sqlUndoLogs":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.undo.SQLUndoLog","sqlType":"UPDATE","tableName":"t_storage","beforeImage":{"@class":"io.seata.rm.datasource.sql.struct.TableRecords","tableName":"t_storage","rows":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Row","fields":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"id","keyType":"PRIMARY_KEY","type":-5,"value":["java.lang.Long",1]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"used","keyType":"NULL","type":4,"value":83},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"residue","keyType":"NULL","type":4,"value":17}]]}]]},"afterImage":{"@class":"io.seata.rm.datasource.sql.struct.TableRecords","tableName":"t_storage","rows":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Row","fields":["java.util.ArrayList",[{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"id","keyType":"PRIMARY_KEY","type":-5,"value":["java.lang.Long",1]},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"used","keyType":"NULL","type":4,"value":93},{"@class":"io.seata.rm.datasource.sql.struct.Field","name":"residue","keyType":"NULL","type":4,"value":7}]]}]]}}]]}
StorageServiceImpl - [decrease,24] - ------->storage-service中扣减库存结束
RootContext - [unbind,140] - unbind 192.168.14.236:8091:6737814217289867327
XidResource - [cleanXid,38] - unbind[192.168.14.236:8091:6737814217289867327] from RootContext
AbstractNettyRemoting - [processMessage,268] - io.seata.core.rpc.netty.RmNettyRemotingClient@21aeb302 msgId:52, body:xid=192.168.14.236:8091:6737814217289867327,branchId=6737814217289867329,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,applicationData=null
RmBranchCommitProcessor - [process,56] - rm client handle branch commit process:xid=192.168.14.236:8091:6737814217289867327,branchId=6737814217289867329,branchType=AT,resourceId=jdbc:mysql://192.168.14.239:3306/ultra_sdc0516,applicationData=null
AbstractRMHandler - [doBranchCommit,96] - Branch committing: 192.168.14.236:8091:6737814217289867327 6737814217289867329 jdbc:mysql://192.168.14.239:3306/ultra_sdc0516 null
AbstractRMHandler - [doBranchCommit,104] - Branch commit result: PhaseTwo_Committed
RmBranchCommitProcessor - [handleBranchCommit,65] - branch commit result:xid=192.168.14.236:8091:6737814217289867327,branchId=6737814217289867329,branchStatus=PhaseTwo_Committed,result code =Success,getMsg =null
AbstractNettyRemoting - [sendAsync,220] - write message:xid=192.168.14.236:8091:6737814217289867327,branchId=6737814217289867329,branchStatus=PhaseTwo_Committed,result code =Success,getMsg =null, channel:[id: 0x0030614b, L:/172.16.5.39:55514 - R:/192.168.14.236:8091],active?true,writable?true,isopen?true
AbstractUndoLogManager - [batchDeleteUndoLog,162] - batch delete undo log size 1
服务调用过程中,全局事务方法会传递 TX_XID 给下一个服务调用的,然后通过 TransactionPropagationInterceptor 从请求头重获取该全局事务ID。