Try
↑ ↓ move↵ openesc close
In this lesson · topic 6 of 7
  1. 1. An order that spans four services
  2. 2. Steps, undos and the reverse order
  3. 3. Fail steps and watch readers see the middle
  4. 4. Atomic in the end, visible in the middle
  5. 5. One conductor or a chain of events
  6. 6. When the undo cannot be done
  7. 7. Compensation, isolation and coordination

Topic 6

When the undo cannot be done

4 min read

An undo is a call like any other

A refund goes through the same network as the charge. It can time out, hit a down service or be refused. The saga cannot leave the order half done, so it retries.

Retries are only safe if the compensation is idempotent. Give each one a key made from the saga id and the step. A second try then returns the first result, and does not refund twice.

Giving up

A retry that never succeeds must have a limit. In the lab, a compensation is tried again up to 4 timesmeasured, and then the saga is parked. At the defaults, 0 sagasmeasured were parked. With half of all undos failing, 3 sagasmeasured were.

A parked saga is a bug report for a person or a repair job. It holds partial state, such as a charge with no refund. Count parked sagas, track their age and alert on them. The count is a direct measure of how well your compensations work.

One more case

A compensation can arrive for a step that never ran, because the request to run it was lost. The undo must notice that there is nothing to cancel, record that fact, and succeed. If the original request arrives late, it must see the record and refuse to run.

Predict first

A refund request arrives for a charge the payment service has no record of. What should it do?

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms