Distributed Transaction on mysql

喜夏-厌秋 提交于 2021-02-11 17:30:57

问题


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.

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 ?


回答1:


I think you can google two-phase commit, it is a very famous and useful protocol for distributed transactions, and this is the wiki from wikipedia Two-phase commit




回答2:


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

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.



来源:https://stackoverflow.com/questions/17772363/distributed-transaction-on-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!