Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【XA】transaction exception handling process #832

Open
luky116 opened this issue Mar 8, 2024 · 2 comments
Open

【XA】transaction exception handling process #832

luky116 opened this issue Mar 8, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request transaction Transaction
Milestone

Comments

@luky116
Copy link
Contributor

luky116 commented Mar 8, 2024

What would you like to be added:

XA transaction exception handling process(XA agent scheduled tasks)

refert to: #822

Why is this needed:

@dongzl dongzl added enhancement New feature or request transaction Transaction labels Mar 9, 2024
@dongzl dongzl added this to the 0.3.0 milestone Mar 12, 2024
@No-SilverBullet
Copy link

plz assign this issue to me @dongzl

@No-SilverBullet
Copy link

No-SilverBullet commented Aug 16, 2024

正常流程异常处理

提交过程

1.PREPARE下发之前有节点失败或报错,关闭连接放弃事务数据

2.PREPARE下发过程中发生失败,则回滚事务,所有节点下发ROLLBACK
3.如果在COMMIT阶段发生失败,则尝试重试(重试次数需做限制或者开放给用户设置),几次尝试失败或者超出期望时间将事务交给定时任务(补偿机制)

回滚过程

如果在ROLLBACK阶段发生失败,则尝试重试(重试次数需做限制或者开放给用户设置),几次尝试失败或者超出期望时间将事务交给定时任务(补偿机制)

异常流程补偿机制

假如出现由于服务下线或者其他原因导致的提交或回滚任务被执行了一半(突然断连),在这种情况发生的时候需要有对应的补偿机制来保证数据的最终一致性。

要点:补偿事务本身也是一个最终一致性操作,因此也可能会失败。因此补偿事务中的步骤应该是幂等的

首先看事务的状态:

状态 解释
TX_STARTED_STATE XA事务处于开始状态,在事务开始直到提交或者回滚之前XA事务的状态一直会保持此状态
TX_PREPARING_STATE XA 事务正在下发prepare
TX_PREPARED_STATE XA PREPARED成功状态
TX_COMMITTING_STATE XA 事务正在提交
TX_ROLLBACKING_STATE XA 事务正在回滚
TX_COMMITTED_STATE XA 事务提交成功
TX_ROLLBACKED_STATE XA 事务回滚成功
TX_COMMIT_FAILED_STATE XA 事务提交失败
TX_ROLLBACK_FAILED_STATE XA 事务回滚失败
  1. prepare执行成功之前

丢弃连接,放弃事务数据,报错

  1. prepare执行成功之后

当某个分支事务的XA prepare执行成功之后,则必须执行XA rollbalk或者XA commit,通过重试尽可能确保执行成功;

  1. 基于2PC实现的情况下,针对一些网络异常情况,arana接收不到响应,也就无法知道prepare、commit、rollback是否成功。针对这些情况,需要有某种方法去延迟确认分支事务的结果从而确认是提交还是回滚或者直接采取回滚的方式。

问题:

  1. 是否可以添加一个超时的事务状态,用于和显示的失败状态区分

参考链接:

https://seata.apache.org/zh-cn/docs/user/appendix/global-transaction-status

https://seata.apache.org/zh-cn/docs/dev/mode/xa-mode

https://actiontech.github.io/dble-docs-cn/2.Function/2.5_distribute_transaction/2.5.1_XA_trans_overview.html

https://learn.microsoft.com/zh-cn/azure/architecture/patterns/retry

https://downloads.mysql.com/docs/refman-5.7-en.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request transaction Transaction
Projects
None yet
Development

No branches or pull requests

3 participants