A pivot transaction is the last saga step that can fail because of a business-rule violation. It is the saga’s go/no-go point: failure can trigger rollback of earlier compensatable steps; success leads to steps expected to complete. Because no later business-rule failure needs to be undone, the pivot needs no compensating transaction and can perform an operation that is difficult or impossible to reverse. section 9.2.2
Structure saga steps around the pivot:
- Before it, use zero or more compensatable transactions that can be rolled back. section 9.2.2
- At the pivot, perform the final step that can fail due to a business rule. section 9.2.2
- After it, use zero or more retriable transactions, which are expected to succeed; transient technical failures may require repeated invocation. section 9.2.2
Order sagas
In Create Order, reserving customer credit is the pivot: if it fails, the order can be rejected; if it succeeds, delivery scheduling follows. In Cancel Order, canceling a delivery is the pivot because a shipped delivery cannot be canceled. In the FTGO Create Order Saga, card authorization is the pivot, followed by approving the order and ticket. section 9.3.1 section 11.1.1
Figure 9.4 A saga’s steps are grouped into three phases: zero or more compensatable transactions, which can be rolled back and so have a compensating transaction, a single pivot transaction, which is saga’s go/no-go point, and zero or more retriable transactions, which are transactions that are guaranteed to complete.
Use the phase diagram to see how compensatable steps, the pivot, and retriable steps fit together. section 9.2.2
Treat the pivot as a business-failure boundary, not as a guarantee of isolation. Concurrent order creation and cancellation can still produce inconsistent outcomes; the FTGO saga uses semantic locks to help other transactions handle entities being updated. section 9.3.1 section 11.1.1
