Action Records and Reconciliation
In this article
- Explain why a restarted agent cannot tell from memory or from an order read whether its refund already went through.
- Write an action record before an outside call and move it through PREPARED, UNCERTAIN and CONFIRMED.
- Reconcile an action in doubt by looking it up by its action id, and say what happens when it is found and when it is not.
- Spot a recovery step that trusts the local record over the provider, or an undo that could run twice.
- Terms defined here: duplicate side effect, durable action state, reconciliation, idempotency.
Overview
Your agent asked a payment provider for a refund. Thirty seconds passed with no answer, and then the process died. A new process starts up and finds the run halfway through. Should it send the refund again? If the first one went through, a second one pays the customer twice. If it never arrived, not sending leaves the customer with nothing.
Take a made-up support agent's run that refunds 49.00 EUR on order 1042 after a manager approves it. The intent to refund was saved, and no receipt was. By the end you can write the small record that lets the new process find out what happened, and you can run a 40-line program that recovers with one refund and one receipt.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- What the restarted process knows
- The action record
- Reconciling by action id
- When the row and the provider disagree
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions