Course contentsShow
← System Design
Lesson 594 of 1,91916. Distributed TransactionsFree lesson

Saga Isolation and Anomalies

Understanding dirty reads, lost updates, and other anomalies that occur because sagas lack ACID isolation guarantees.

Saga Isolation and Anomalies

What you'll learn: You'll understand the key problems that arise when sagas give up ACID isolation, including dirty reads, lost updates, and other concurrency anomalies.

The Isolation Problem in Sagas

Remember that sagas break a long transaction into multiple smaller local transactions, each committed independently. This gives us better availability and performance than traditional distributed transactions, but comes with a significant cost: we lose isolation.

In ACID transactions, isolation means other transactions don't see your intermediate states. With sagas, every local transaction commits immediately, making its changes visible to everyone—even though the overall saga might still fail and roll back later via compensating transactions.

Common Anomalies

Dirty Reads

Other transactions can read data written by a saga that hasn't completed yet. If the saga later fails and compensates, those readers saw "dirty" data that was effectively undone.

Example: Your saga reserves inventory (commits), then fails at payment. Another customer sees "1 item left" and doesn't order, even though your reservation will be rolled back.

Lost Updates

Two sagas might read the same data, modify it, and write back—the second write overwrites the first without seeing its changes.

Example: Two sagas both read account balance 100,eachadd100, each add 50, both write 150.Finalbalanceis150. Final balance is 150, not $200.

Non-Repeatable Reads

A saga reads the same data twice and gets different values because another saga modified it in between.

These anomalies happen because saga steps are visible as they execute, not hidden until the end like in isolated transactions.

Key Takeaway: Sagas sacrifice isolation for availability—intermediate states are visible, leading to dirty reads, lost updates, and other anomalies that require careful handling through semantic locks, version checks, or accepting eventual consistency.