mysql上的分布式事务 [英] Distributed Transaction on mysql

查看:100
本文介绍了mysql上的分布式事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用分布式事务的分布式系统上工作,这意味着我可能有一个需要同时编辑多个数据库(在多个服务器上)的事务.

I'm working on a distributed system that uses distributed transactions, which means that I may have a transaction that needs to edit multiple databases (on multiple servers) at the same time.

在我的系统中,有一个控制器来管理分发.

In my system there is a controller to manage the distribution.

我要满足的方案是:服务器A希望启动分布式事务.参与者是服务器A和服务器B.因此服务器A向控制器发送请求以发起分布式事务.控制器打开与服务器A和服务器B的连接,并要求它们进行本地事务.服务器A和服务器B都必须回复服务器它们已准备就绪.控制器然后将提交发送到服务器A和服务器B.

the scenario that I want to satisfy is: server A wants to initiate a distributed transaction. the participants are server A and server B. so server A sends a request to the controller to initiate a distributed transaction. the controller opens a connection to server A and to server B and ask them to do local transactions. both server A and server B must reply the server that they are ready. the controller then sends commit to both server A and server B.

您对我有什么建议能够建立此分布式事务?

Do you have any advice for me to be able to build this distributed transaction ?

推荐答案

两阶段提交是您想要的,就像BitHigher提到的那样.也称为 XA交易.对于特定于MySQL的操作,请阅读.

Two phase commit is what you want, as BitHigher mentions. It's also known as XA transactions. For MySQL specific operations, read this.

请注意,XA会有其自身的复杂性,特别是在失败的情况下.尝试使用XA之前,请确保您了解所有的极端情况.

Note that XA will come with its own complications, especially in cases of failures. Make sure you understand all the corner cases before attempting to use XA.

这篇关于mysql上的分布式事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆