Saga Pattern
A classic design pattern in distributed systems for handling long-running transactions, originating from a 1987 database paper by Hector Garcia-Molina. It decomposes a long transaction into a sequence of ordered local transactions, each accompanied by a compensating transaction, and supports both orchestration and choreography coordination styles.
Core Facts
Timeline (last 90 days)
The Saga pattern was first proposed by Hector Garcia-Molina and Kenneth Salem in 1987 to solve the problem that long transactions cannot hold locks; its core is splitting a long transaction into several local transactions T1…Tn, each Ti paired with a compensating action Ci, and if Tk fails, executing C(k-1)…C1 in reverse order.
Payment systems typically use Saga or TCC (Try-Confirm-Cancel) to balance consistency and availability, together with idempotent design and compensation mechanisms.
To implement Saga in a state machine framework like LangGraph, the key is to maintain an ordered list of "completed forward nodes" and to ensure that each compensation handler can determine from the idempotency key whether it has already been executed.
The compensation handler adopts the Saga pattern, executing compensating actions in reverse order when a subsequent node fails, undoing steps that have already taken effect (such as releasing an already-occupied quota or revoking a notification).
The Saga pattern differs from two-phase commit (2PC) in that it does not require resource locking, making it more suitable for cross-service scenarios involving external APIs, but it can only guarantee eventual consistency, and the compensating actions themselves must also be idempotent.
The Saga pattern was first proposed by Garcia-Molina and Salem in 1987 to solve the problem that long transactions in distributed systems cannot rely on a single database transaction to guarantee atomicity.
An atomic transaction requires a set of database operations to either all succeed or all roll back, and typical implementations rely on the ACID properties of relational databases; in distributed environments, two-phase commit (2PC) or the Saga pattern must also be introduced to coordinate cross-service transactions.
Currently no mainstream Agent framework natively implements the Saga pattern with compensation for LLM workflows.
The engineering alternative to strict atomicity usually adopts the Saga pattern or compensating transactions, recording the success/failure status and corresponding cost of each step.
A compensating transaction is the standard pattern in distributed systems for handling non-rollbackable operations, originating from the Saga pattern, which offsets the effects of each completed step by performing a semantically opposite operation.
10 more timeline events
All Facts (20)
Compensating transactions are the core idea of the Saga pattern, undoing the side effects of non-rollback-able steps by executing logically inverse operations.
65%UnverifiedThe Saga pattern originated from a 1987 paper by Hector Garcia-Molina and Kenneth Salem, initially used to address the problem of long-running database transactions.
60%UnverifiedThe Saga pattern was first proposed by Hector Garcia-Molina and Kenneth Salem in 1987 to solve the problem that long transactions cannot hold locks; its core is splitting a long transaction into several local transactions T1…Tn, each Ti paired with a compensating action Ci, and if Tk fails, executing C(k-1)…C1 in reverse order.
50%UnverifiedPayment systems typically use Saga or TCC (Try-Confirm-Cancel) to balance consistency and availability, together with idempotent design and compensation mechanisms.
50%UnverifiedTo implement Saga in a state machine framework like LangGraph, the key is to maintain an ordered list of "completed forward nodes" and to ensure that each compensation handler can determine from the idempotency key whether it has already been executed.
50%UnverifiedThe compensation handler adopts the Saga pattern, executing compensating actions in reverse order when a subsequent node fails, undoing steps that have already taken effect (such as releasing an already-occupied quota or revoking a notification).
50%UnverifiedThe Saga pattern was first proposed by Garcia-Molina and Salem in 1987 to solve the problem that long transactions in distributed systems cannot rely on a single database transaction to guarantee atomicity.
50%UnverifiedThe Saga pattern differs from two-phase commit (2PC) in that it does not require resource locking, making it more suitable for cross-service scenarios involving external APIs, but it can only guarantee eventual consistency, and the compensating actions themselves must also be idempotent.
50%UnverifiedAn atomic transaction requires a set of database operations to either all succeed or all roll back, and typical implementations rely on the ACID properties of relational databases; in distributed environments, two-phase commit (2PC) or the Saga pattern must also be introduced to coordinate cross-service transactions.
50%UnverifiedCurrently no mainstream Agent framework natively implements the Saga pattern with compensation for LLM workflows.
50%UnverifiedThe engineering alternative to strict atomicity usually adopts the Saga pattern or compensating transactions, recording the success/failure status and corresponding cost of each step.
50%UnverifiedA compensating transaction is the standard pattern in distributed systems for handling non-rollbackable operations, originating from the Saga pattern, which offsets the effects of each completed step by performing a semantically opposite operation.
50%UnverifiedThe Saga pattern is a common solution for handling cross-service data consistency in distributed systems, breaking a long transaction into a series of local transactions equipped with compensating operations.
50%UnverifiedThe Saga pattern has two common implementation styles: orchestration (directed by a central coordinator) and choreography (services triggering each other through events).
50%UnverifiedThe Saga pattern breaks a large transaction into a series of local transactions T1…Tn, each Ti paired with a compensating transaction Ci; on failure, the compensation actions are executed in reverse order to return the whole to a consistent state.
50%UnverifiedSaga's compensation is not a physical rollback and cannot restore side effects already consumed by external systems; it can only perform semantically equivalent reverse operations.
50%UnverifiedThe Saga pattern was first proposed by Hector Garcia-Molina and Kenneth Salem in 1987 to solve the problem that long transactions are difficult to keep atomic in distributed databases.
50%UnverifiedSaga's compensating transactions are logically a semantic undo rather than a physical rollback, and their idempotency and reliability must be carefully designed by developers.
50%UnverifiedThe Saga pattern was proposed by Hector Garcia-Molina of Princeton University in 1987.
50%UnverifiedAgentWall provides a rollback hook mechanism that executes registered compensating actions in reverse order when a session fails, a design inspired by the Saga pattern.
50%