liveBook · Manning

Pivot transaction

As explained in Microservices Patterns, Second Edition

A saga transaction that marks the point after which the saga must complete through forward recovery or subsequent noncompensatable actions.

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.
three phase saga

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

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines the pivot and its neighboring phases, then illustrates their placement in order workflows.
Examples
Uses order creation, order cancellation, credit reservation, delivery cancellation, and card authorization.
What you can do after
Evaluate saga steps to identify which actions need compensation and which follow the final business-rule failure point.
How it connects
Connects sagas with compensating transactions, retries, business rules, and semantic locks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.