Rehearse failure and recovery
Prove idempotency, rollback, and observability under adverse timelines.
List the failure points
Draw the checkout timeline from request validation to database commit, queue dispatch, payment response, and receipt. For each boundary, ask what happens if the process stops immediately before or after it. The most dangerous state is often an uncertain external result: the charge may have completed while the response was lost.
Inject one fault at a time
Use a fake provider or isolated test environment to drop a response, delay a worker, duplicate an event, and fail a database write. Assert final business state: one charge, one entitlement, and an actionable retry record. A passing unit test for a helper is weaker than a recovery test through the whole workflow.
Scenario: payment succeeds; response times out.
Replay: same operation key.
Invariant: one charge and one entitlement.
Turn results into operations
Record how an operator discovers stuck work, which command or UI safely retries it, and what evidence confirms completion. Monitor queue age and reconciliation mismatches. Re-run the rehearsal after changing the payment adapter or queue topology; resilience is a maintained property, not a one-time test.
Check your understanding
What is the key assertion when a payment response is lost after success?
Show explanation
A retry with the same operation key produces one charge and one entitlement, with a clear final state.
You can read for free. Create an account to save your progress.
← Previous lesson: Change a live schema safelyTry it at senior level
Rehearse a payment webhook arriving twice while the queue is delayed. Write the timeline, expected ledger entries, and recovery steps.
Check your work
Only one grant exists, pending work is observable, and replay after recovery reaches the same final state.
Self-guided practice. This does not record assessed mastery.
Put this lesson into practice
A related activity in this module at mid level.
Try: Deduplicate a payment webhookFurther reading
Primary references for this module. Check the current version when behavior or framework guidance may have changed.