Narayana 事务回滚流程
当用户手动调用 connection.rollback() 回滚当前全局事务时,会走如下流程。
总体流程
1 2 3 4
| 遍历每个 resource 执行 xa end; 执行 xa rollback; 清理缓存
|
使用
1 2 3 4 5 6 7
| TransactionManager transactionManager = jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager();
transactionManager.begin();
transactionManager.rollback();
|
调用链路
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#rollback com.arjuna.ats.arjuna.coordinator.BasicAction#status 获取当前事务状态 com.arjuna.ats.arjuna.AtomicAction#cancel 回滚流程 com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator#cancel com.arjuna.ats.arjuna.coordinator.BasicAction#parent com.arjuna.ats.arjuna.coordinator.BasicAction#Abort 回滚流程 com.arjuna.ats.arjuna.coordinator.BasicAction#checkIsCurrent com.arjuna.ats.arjuna.coordinator.BasicAction#checkChildren com.arjuna.ats.arjuna.coordinator.BasicAction#doAbort com.arjuna.ats.arjuna.coordinator.RecordList#getFront 遍历 record list 里的 resource 依次回滚 com.arjuna.ats.arjuna.coordinator.AbstractRecord#getNext com.arjuna.ats.arjuna.coordinator.BasicAction#doAbort resource1 执行回滚 com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#toString com.arjuna.ats.jta.xa.XidImple#toString com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#topLevelAbort com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#toString com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#getXAResourceState com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#endAssociation com.arjuna.ats.jta.xa.XidImple#toString com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#toString com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction#toString com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#toString com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#endAssociation com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#getXAResourceState com.arjuna.ats.internal.jta.xa.TxInfo#getState com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#doEnd com.zc.transaction.xa.SingleXACtrlResource#end 执行 xa end 操作 com.arjuna.ats.jta.xa.XidImple#getGlobalTransactionId com.arjuna.ats.jta.xa.XidImple#getBranchQualifier com.arjuna.ats.jta.xa.XidImple#getFormatId com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#setXAResourceState com.arjuna.ats.internal.jta.xa.TxInfo#setState com.zc.transaction.xa.SingleXACtrlResource#rollback 执行 xa rollback 操作 com.arjuna.ats.jta.xa.XidImple#toString com.arjuna.ats.jta.xa.XidImple#getGlobalTransactionId com.arjuna.ats.jta.xa.XidImple#getBranchQualifier com.arjuna.ats.jta.xa.XidImple#getFormatId com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#removeConnection com.arjuna.ats.arjuna.coordinator.BasicAction#updateHeuristic com.arjuna.ats.arjuna.StateManager#get_uid com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#order com.arjuna.common.internal.util.propertyservice.BeanPopulator#getDefaultInstance com.arjuna.ats.arjuna.common.CoreEnvironmentBean#getNodeIdentifier com.arjuna.ats.arjuna.coordinator.BasicAction#doAbort resource2 执行回滚 com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#topLevelAbort resource2 执行相同的 xa end + xa rollback 操作 com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#getXAResourceState com.arjuna.ats.internal.jta.xa.TxInfo#getState com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#endAssociation com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#endAssociation com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#getXAResourceState com.arjuna.ats.internal.jta.xa.TxInfo#getState com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#doEnd com.zc.transaction.xa.SingleXACtrlResource#end 执行xa end com.zc.transaction.xa.SingleXACtrlResource#rollback 执行 xa rollback ...... com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord#removeConnection com.arjuna.ats.arjuna.coordinator.BasicAction#updateHeuristic com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator#afterCompletion com.arjuna.ats.arjuna.coordinator.TransactionReaper#transactionReaper com.arjuna.ats.arjuna.coordinator.TransactionReaper#remove 事务超时监控缓存清理 com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple#removeTransaction 事务缓存清理
|