0

I've just read this article, about handling distributed transactions in the microservices world.

In the article, the author explained two possible solutions available.

I'm familiar with SAGA. But never actually tried the Two-Phase Commit pattern.

And here we go with my question:

In the Two-Phase Commit pattern, how to handle data inconsistency if suddenly in the middle of the process, the transaction coordinator service is down? If it happens in the middle of the process, some data on certain services may be updated already.

2
  • Did you mean the "transaction coordinator?" Oct 12, 2020 at 15:00
  • yes. let me update it to make it clear
    – novalagung
    Oct 12, 2020 at 15:00

1 Answer 1

4

If you are looking for possible failures, you will find some. According to the CAP theorem distributed transactions can not be 100% safe, not in the "database" isolation-level-atomicity sense.

In a distributed system you'll always have to have some compromise. This is why distributed transactions are usually regarded as an anti-pattern in a microservices environment. First, it can not be done (with 100 percent reliability). Second, it makes things unnecessarily complex.

Usually it is better to design your way around the need for distributed transactions by properly choosing where certain functionalities are, or ordering steps in some way, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.