Interview knowledge

Distributed transactions

Growingest.Started 7 Sept 20261 min read#database#engineering

Inspired by Distributed Transactions Explained: 2 Phase Commit vs Saga Pattern

Where it sits: Distributed transactions

2 phase commit and saga patterns are the most common ways to solve this.

2 phase commit (2PC)

You can have a coordinator plan across services and commit all at once, but this is fragile if the coordinator dies.

All or nothing is hard on distributed systems, so you opt in for eventual consistency instead

Saga pattern

What's more common is the saga pattern.
You create business level undos. Once a transaction is committed, it is committed. But if one system fails, it can notify the other systems to undo somehow.

There is a temporary inconsistent state while it fixes itself but the systems are still available
The undo scenarios need to be really reliable too.

Sources