xresco
xresco

Reputation: 11

Distributed Transaction on 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.

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 ?

Upvotes: 0

Views: 7158

Answers (2)

user10996
user10996

Reputation:

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.

Upvotes: 0

BitHigher
BitHigher

Reputation: 501

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

Upvotes: 1

Related Questions