The concept Accepted here, failed three steps later
Enterprise applications communicate across networks, queues, databases, APIs and vendors. A transaction can be accepted by one component and fail several steps later. That makes distributed investigation very different from debugging one program.
| Failure | What happens | Typical reasons |
|---|---|---|
| Duplicate delivery | The consumer receives the same event twice | Producer retries, consumer fails before acknowledging, network interruption, broker redelivery |
| Delayed delivery | Published at 09:00, consumed at 09:20 | Backlog, consumer down, too little capacity, slow downstream dependency |
| Out-of-order events | Captured arrives before authorized | Parallel processing, retries, several partitions |
| Partial failure | One write succeeds, the next does not | No shared transaction across systems |
| Timeout, unknown outcome | The work completed but the reply was lost | Slow downstream service, network break |
| Data inconsistency | Two systems describe one event differently | Wrong mapping, ID formats, time zones, status meanings, rounding |
The key idea Idempotency
Idempotency means repeating an operation with the same identity does not create an extra effect. Pressing a lift button five times still calls one lift. When event EVT9001 arrives twice, a well-designed consumer recognizes it and does not post the payment again:
- Receive the event.
- Validate its identity.
- Check whether it has already been applied.
- If it has, record the duplicate delivery and stop.
- Otherwise, perform the business operation.
- Record the outcome safely.
Retries Retry carefully
| Failure | Usually the right response |
|---|---|
| Temporary network error | Retry |
| Validation error | Fix the data; retrying will fail the same way |
| Authorization failure | Fix credentials or permissions |
| Timeout | Check whether the operation already happened |
| Downstream outage | Back off and recover in a controlled way |
A common strategy is exponential backoff with jitter: wait longer after each failure, plus a small random amount, so that thousands of failed requests do not all retry at the same instant. The retry policy must still match the safety of the operation and the capacity of the downstream system.
Recovery Dead-letter queues
Messages that fail repeatedly may be moved to a dead-letter queue: a controlled holding area for investigation and recovery. Before you touch one, ask why it failed, whether the message is malformed, whether the failure is temporary or permanent, whether it can be safely corrected and replayed, whether part of the business operation already happened, and who authorizes the recovery.
The method A ten-step root-cause method
- Pick one affected business transaction.
- Find its identifiers in every participating system.
- Build a timestamped execution timeline.
- Find where expected behavior and actual behavior diverge.
- Collect supporting logs, traces, records and metrics.
- Develop several possible explanations.
- Test each explanation against the evidence.
- Confirm the cause, or write down what is still unknown.
- Determine the business and operational impact.
- Recommend a correction and a way to prevent it happening again.
Practice Name the failure mode
Practical exercise
Four short cases
For each case, name the failure mode and the first evidence you would collect.
- Some borrowers show a payment status of authorized even though the provider reports captured.
- Payments made at 8:55 a.m. appear in loan servicing at 9:20 a.m. every Monday.
- A payment appears in loan servicing but not in the audit history.
- After a network blip, one payment was posted twice.
Show sample answers
- Out-of-order events: captured processed first, then overwritten by a late authorized. Evidence: occurred and received timestamps for both events.
- Delayed delivery: consumer lag on Monday mornings. Evidence: queue depth and consumer lag metrics for Mondays.
- Partial failure: the posting committed, the audit write did not. Evidence: logs around the posting time, and whether both writes share a transaction.
- Timeout with unknown outcome plus a blind retry: no idempotency. Evidence: logs for both attempts and the event ID on both postings.
3 questions
Check your understanding
What you can do now
- Recognize the six distributed failure modes.
- Explain idempotency and why check-then-insert is not enough.
- Choose the right response to each kind of failure.
- Handle dead-letter queues safely and follow the ten-step method.