Lesson 9 of 9 · 26m
Dependency-Aware Recovery and Data Reconciliation
Restore interconnected systems in coherent order, reconcile RPO gaps across stores, and prevent recovered applications from causing duplicate or corrupt side effects.
The backup may restore perfectly and the service can still be wrong. Modern applications split truth across databases, object stores, queues, search indexes, caches, third-party services, and user devices. Recovery is reconciliation: deciding which store is authoritative, accepting loss windows honestly, and preventing the application from re-executing yesterday's side effects.
Pick the source of truth per fact
Not per service — per fact:
customer identity -> identity database; invoice ledger -> billing database
invoice PDF bytes -> object storage; email delivery -> external provider
search/cache -> rebuildable or disposable; outbox events -> dangerous unless deduplicatedThis table drives recovery behavior. If invoice rows survive but PDFs do not, regeneration may be acceptable. If rows are lost but PDFs remain, you have forensic evidence but not a coherent ledger.
RPO mismatch creates application corruption
Suppose the database recovers to 02:00, object storage to 02:20, and queue state to 01:50. Rows may reference objects that do not exist. Events may fire twice. Search results may include deleted tenants. The fix is not 'restore everything harder'; it is an explicit reconciliation plan:
SELECT invoice_id, object_key FROM invoices WHERE object_key IS NOT NULL;Compare those keys with object-store inventory. Quarantine or repair mismatches before opening traffic. For high-volume systems, reconcile with jobs and manifests rather than interactive SQL.
Pause write amplifiers
Before users return, pause workers that send email, charge cards, sync external systems, or consume queues. Applications often retry side effects automatically. A restored system can spam customers, duplicate payouts, or reissue credentials while looking 'healthy' in uptime checks.
systemctl stop billing-worker.service
systemctl mask billing-worker.service # during recovery only; unmask after validationIdempotency is a recovery feature
Systems recover better when operations can be safely repeated. Store idempotency keys with externally visible actions and check them before executing:
if ledger_action_exists(idempotency_key):
return existing_action_result
record_and_execute(idempotency_key, action)During restore, idempotency markers may themselves be rolled back. Where possible, external providers should be queried before retrying high-impact actions such as payments or license creation.
Rebuildable does not mean instant
Indexes, caches, thumbnails, analytics rollups, and search clusters are often labeled rebuildable, then nobody budgets rebuild time. Measure it. If rebuilding search takes fourteen hours and support depends on search, recovery is not complete when the database is back. Include rebuild status in readiness checks.
Communicate data loss shape
Customers care about what is missing, not your backup architecture. During recovery produce a precise statement: records created after time X are unavailable, uploads between X and Y are being reconciled, emails may not be re-sent, audit events are preserved. Internal honesty enables correct support and legal decisions.
Field notes
- Never let application health checks pass merely because processes are running; readiness must include data reconciliation state.
- Treat queue consumers as potentially destructive during recovery until event semantics are reviewed.
- The hardest question — 'which version of truth wins?' — should be answered in design documents before adrenaline arrives.
Was this lesson helpful?