二阶段提交:
成功--》日志:
调用发起方:
2021-05-17 11:09:51.917 INFO 11044 --- [nio-8081-exec-9] i.seata.tm.api.DefaultGlobalTransaction : Begin new global transaction [192.168.20.215:8091:137514650748063744]
2021-05-17 11:09:51.917 INFO 11044 --- [nio-8081-exec-9] icu.funkye.controller.TestController : -----testCommit----
2021-05-17 11:09:51.930 INFO 11044 --- [nio-8081-exec-9] icu.funkye.controller.TestController : seata分布式事务Id:192.168.20.215:8091:137514650748063744
2021-05-17 11:09:52.828 INFO 11044 --- [nio-8081-exec-9] i.seata.tm.api.DefaultGlobalTransaction : [192.168.20.215:8091:137514650748063744] commit status: Committed
被调用方1:
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@899276f] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@65ec80c] will not be managed by Spring
Original SQL: SELECT id,user_name,sum,last_update_time FROM account WHERE id=?
parser sql: SELECT id, user_name, sum, last_update_time FROM account WHERE id = ?
==> Preparing: SELECT id, user_name, sum, last_update_time FROM account WHERE id = ?
==> Parameters: 1(Integer)
<== Columns: id, user_name, sum, last_update_time
<== Row: 1, 1, 6, 2021-05-17 03:07:44
<== Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@899276f]
2021-05-17 11:09:51.942 WARN 2088 --- [io-8085-exec-10] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137514650748063744 to null
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28103729] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@7388738d] will not be managed by Spring
Original SQL: UPDATE account SET user_name=?,
sum=?,
last_update_time=? WHERE id=?
parser sql: UPDATE account SET user_name = ?, sum = ?, last_update_time = ? WHERE id = ?
==> Preparing: UPDATE account SET user_name = ?, sum = ?, last_update_time = ? WHERE id = ?
==> Parameters: 1(String), 7(Integer), 2021-05-17T11:09:51.930(LocalDateTime), 1(Integer)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@28103729]
2021-05-17 11:09:52.315 WARN 2088 --- [nio-8085-exec-1] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137514650748063744 to null
2021-05-17 11:09:53.393 INFO 2088 --- [h_RMROLE_1_4_16] i.s.c.r.p.c.RmBranchCommitProcessor : rm client handle branch commit process:xid=192.168.20.215:8091:137514650748063744,branchId=137514651914080257,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/test_pay,applicationData=null
2021-05-17 11:09:53.393 INFO 2088 --- [h_RMROLE_1_4_16] io.seata.rm.AbstractRMHandler : Branch committing: 192.168.20.215:8091:137514650748063744 137514651914080257 jdbc:mysql://127.0.0.1:3306/test_pay null
2021-05-17 11:09:53.393 INFO 2088 --- [h_RMROLE_1_4_16] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
被调用方2:
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d3f4670] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@13f8aba7] will not be managed by Spring
Original SQL: INSERT INTO orders ( product_id,
amount,
sum,
account_id,
create_time,
replace_time ) VALUES ( ?,
?,
?,
?,
?,
? )
parser sql: INSERT INTO orders (product_id, amount, sum, account_id, create_time, replace_time) VALUES (?, ?, ?, ?, ?, ?)
==> Preparing: INSERT INTO orders (product_id, amount, sum, account_id, create_time, replace_time) VALUES (?, ?, ?, ?, ?, ?)
==> Parameters: 1(Integer), 5.0(BigDecimal), 1(Integer), 1(Integer), 2021-05-17T11:09:51.930(LocalDateTime), 2021-05-17T11:09:51.930(LocalDateTime)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d3f4670]
2021-05-17 11:09:52.501 WARN 12592 --- [nio-8084-exec-3] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137514650748063744 to null
2021-05-17 11:09:53.427 INFO 12592 --- [h_RMROLE_1_2_16] i.s.c.r.p.c.RmBranchCommitProcessor : rm client handle branch commit process:xid=192.168.20.215:8091:137514650748063744,branchId=137514652849410049,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/test_order,applicationData=null
2021-05-17 11:09:53.427 INFO 12592 --- [h_RMROLE_1_2_16] io.seata.rm.AbstractRMHandler : Branch committing: 192.168.20.215:8091:137514650748063744 137514652849410049 jdbc:mysql://127.0.0.1:3306/test_order null
2021-05-17 11:09:53.427 INFO 12592 --- [h_RMROLE_1_2_16] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
被调用方3:
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e9c96c5] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@305b7f66] will not be managed by Spring
Original SQL: SELECT id,price,stock,last_update_time FROM product WHERE id=?
parser sql: SELECT id, price, stock, last_update_time FROM product WHERE id = ?
==> Preparing: SELECT id, price, stock, last_update_time FROM product WHERE id = ?
==> Parameters: 1(Integer)
<== Columns: id, price, stock, last_update_time
<== Row: 1, 5.0, 4, 2021-04-22 00:16:21
<== Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e9c96c5]
2021-05-17 11:09:51.929 WARN 9768 --- [io-8083-exec-10] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137514650748063744 to null
2021-05-17 11:09:51.946 INFO 9768 --- [nio-8083-exec-1] icu.funkye.controller.ProductController : product:Product(id=1, price=5.0, stock=3, lastUpdateTime=2021-04-22T00:16:21)
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@394872fb] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@1526dd31] will not be managed by Spring
Original SQL: UPDATE product SET price=?,
stock=?,
last_update_time=? WHERE id=?
parser sql: UPDATE product SET price = ?, stock = ?, last_update_time = ? WHERE id = ?
==> Preparing: UPDATE product SET price = ?, stock = ?, last_update_time = ? WHERE id = ?
==> Parameters: 5.0(BigDecimal), 3(Integer), 2021-04-22T00:16:21(LocalDateTime), 1(Integer)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@394872fb]
2021-05-17 11:09:52.095 WARN 9768 --- [nio-8083-exec-1] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137514650748063744 to null
2021-05-17 11:09:53.336 INFO 9768 --- [h_RMROLE_1_4_16] i.s.c.r.p.c.RmBranchCommitProcessor : rm client handle branch commit process:xid=192.168.20.215:8091:137514650748063744,branchId=137514651251380225,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/test_storage,applicationData=null
2021-05-17 11:09:53.336 INFO 9768 --- [h_RMROLE_1_4_16] io.seata.rm.AbstractRMHandler : Branch committing: 192.168.20.215:8091:137514650748063744 137514651251380225 jdbc:mysql://127.0.0.1:3306/test_storage null
2021-05-17 11:09:53.336 INFO 9768 --- [h_RMROLE_1_4_16] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
回滚--》日志
调用发起方:
2021-05-17 11:14:44.754 INFO 11044 --- [nio-8081-exec-2] i.seata.tm.api.DefaultGlobalTransaction : Begin new global transaction [192.168.20.215:8091:137515878882217984]
2021-05-17 11:14:44.754 INFO 11044 --- [nio-8081-exec-2] icu.funkye.controller.TestController : -----testCommit----
2021-05-17 11:14:44.767 INFO 11044 --- [nio-8081-exec-2] icu.funkye.controller.TestController : seata分布式事务Id:192.168.20.215:8091:137515878882217984
2021-05-17 11:14:45.784 INFO 11044 --- [nio-8081-exec-2] i.seata.tm.api.DefaultGlobalTransaction : [192.168.20.215:8091:137515878882217984] rollback status: Rollbacked
2021-05-17 11:14:45.786 ERROR 11044 --- [nio-8081-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ArithmeticException: / by zero] with root cause
java.lang.ArithmeticException: / by zero
...exception详细信息
被调用方1:
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a1a1a16] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@44ddfd25] will not be managed by Spring
Original SQL: SELECT id,user_name,sum,last_update_time FROM account WHERE id=?
parser sql: SELECT id, user_name, sum, last_update_time FROM account WHERE id = ?
==> Preparing: SELECT id, user_name, sum, last_update_time FROM account WHERE id = ?
==> Parameters: 1(Integer)
<== Columns: id, user_name, sum, last_update_time
<== Row: 1, 1, 7, 2021-05-17 03:09:52
<== Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a1a1a16]
2021-05-17 11:14:44.778 WARN 2088 --- [nio-8085-exec-5] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137515878882217984 to null
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53293828] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@510709a3] will not be managed by Spring
Original SQL: UPDATE account SET user_name=?,
sum=?,
last_update_time=? WHERE id=?
parser sql: UPDATE account SET user_name = ?, sum = ?, last_update_time = ? WHERE id = ?
==> Preparing: UPDATE account SET user_name = ?, sum = ?, last_update_time = ? WHERE id = ?
==> Parameters: 1(String), 8(Integer), 2021-05-17T11:14:44.767(LocalDateTime), 1(Integer)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53293828]
2021-05-17 11:14:45.111 WARN 2088 --- [nio-8085-exec-6] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137515878882217984 to null
2021-05-17 11:14:45.178 INFO 2088 --- [h_RMROLE_1_5_16] i.s.c.r.p.c.RmBranchRollbackProcessor : rm handle branch rollback process:xid=192.168.20.215:8091:137515878882217984,branchId=137515880132120577,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/test_pay,applicationData=null
2021-05-17 11:14:45.178 INFO 2088 --- [h_RMROLE_1_5_16] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.20.215:8091:137515878882217984 137515880132120577 jdbc:mysql://127.0.0.1:3306/test_pay
2021-05-17 11:14:45.184 INFO 2088 --- [h_RMROLE_1_5_16] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.20.215:8091:137515878882217984 branch 137515880132120577, undo_log deleted with GlobalFinished
2021-05-17 11:14:45.185 INFO 2088 --- [h_RMROLE_1_5_16] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
被调用方2:
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@59de6e] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@e9e3015] will not be managed by Spring
Original SQL: SELECT id,price,stock,last_update_time FROM product WHERE id=?
parser sql: SELECT id, price, stock, last_update_time FROM product WHERE id = ?
==> Preparing: SELECT id, price, stock, last_update_time FROM product WHERE id = ?
==> Parameters: 1(Integer)
<== Columns: id, price, stock, last_update_time
<== Row: 1, 5.0, 3, 2021-04-21 16:16:21
<== Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@59de6e]
2021-05-17 11:14:44.766 WARN 9768 --- [nio-8083-exec-6] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137515878882217984 to null
2021-05-17 11:14:44.783 INFO 9768 --- [nio-8083-exec-2] icu.funkye.controller.ProductController : product:Product(id=1, price=5.0, stock=2, lastUpdateTime=2021-04-21T16:16:21)
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6606111b] was not registered for synchronization because synchronization is not active
JDBC Connection [io.seata.rm.datasource.ConnectionProxy@28376a2c] will not be managed by Spring
Original SQL: UPDATE product SET price=?,
stock=?,
last_update_time=? WHERE id=?
parser sql: UPDATE product SET price = ?, stock = ?, last_update_time = ? WHERE id = ?
==> Preparing: UPDATE product SET price = ?, stock = ?, last_update_time = ? WHERE id = ?
==> Parameters: 5.0(BigDecimal), 2(Integer), 2021-04-21T16:16:21(LocalDateTime), 1(Integer)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6606111b]
2021-05-17 11:14:44.935 WARN 9768 --- [nio-8083-exec-2] c.a.c.seata.web.SeataHandlerInterceptor : xid in change during RPC from 192.168.20.215:8091:137515878882217984 to null
2021-05-17 11:14:45.314 INFO 9768 --- [h_RMROLE_1_5_16] i.s.c.r.p.c.RmBranchRollbackProcessor : rm handle branch rollback process:xid=192.168.20.215:8091:137515878882217984,branchId=137515879482003457,branchType=AT,resourceId=jdbc:mysql://127.0.0.1:3306/test_storage,applicationData=null
2021-05-17 11:14:45.315 INFO 9768 --- [h_RMROLE_1_5_16] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.20.215:8091:137515878882217984 137515879482003457 jdbc:mysql://127.0.0.1:3306/test_storage
2021-05-17 11:14:45.326 INFO 9768 --- [h_RMROLE_1_5_16] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.20.215:8091:137515878882217984 branch 137515879482003457, undo_log deleted with GlobalFinished
2021-05-17 11:14:45.326 INFO 9768 --- [h_RMROLE_1_5_16] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
被调用方3:
调用2后抛出异常,所以没有调用3