Reliability and consistency: understand the problem
- Source
- From the Staff AI System Design course
- By
- Sourav Banerjee
- Last updated
- 8 Nov 2026
Alice receives a saved supplier answer, refreshes the page, and sees no result because the next read reached a lagging replica. The client retries. Meanwhile a provider timeout and a policy-authority outage tempt the application to regenerate blindly or use an old cached permission. Reliability must preserve the meaning of saved success and current authority while recovering useful service.
This continues the same hypothetical platform. The executable uses two SQLite files with explicit event delivery to model a primary and a projection, logical failures, and a local circuit breaker. It is not database replication, consensus, leader election, real failover or a production telemetry deployment. Workloads and timings are illustrative. Estimated integrated study: eight to ten hours; learner mastery remains unassessed.
Inherit Security and Execution Before Adding Recovery
T18.7, its snapshot and ADR-006 establish verified scope, current membership/resource policy and mandatory audit-before-disclosure. Keep fair admission/provider budgets, shared history and keys, source versions, safe immutable caches, worker epochs, and explicit unknown remote outcomes.
Before diagram. Shared authority is a logical contract; actual availability, replication and recovery guarantees have not been deployed or measured in earlier stages.
Walk Through the Incident
The primary commits Alice's answer and acknowledges success. A derived history copy has not received that commit. Reading the copy without a freshness requirement yields “not found,” although the answer is durable. Reissuing generation with a new operation key can charge again. If the original response was lost instead, the client cannot know from the timeout alone whether the commit happened.
Now imagine the failed dependency is policy authority. A stale replica may still say Alice belongs to Tenant A. Serving protected context from it would turn an availability fallback into an access regression. Recovery rules must depend on the data class, not the fact that another server can respond.
| Concrete observation | Term | Consequence |
|---|---|---|
| Two copies temporarily disagree after a commit | Replication lag | A readable replica need not contain the acknowledged write |
| Alice's next read must include her saved result | Read-your-write contract | Carry a trusted minimum version or route to authority |
| The result and its notification must agree | Transactional outbox | Commit intent with local state; delivery can still repeat |
| Stop calling an unhealthy dependency repeatedly | Circuit breaker | Limits attempts; does not repair the dependency or prove remote cancellation |
| Follow one request across services and waits | Distributed trace | Correlated timings explain a path, not every unsampled failure |
What This Module Covers
| Module | Treatment | Depth and evidence |
|---|---|---|
| Distributed system fundamentals | Taught here | Build depth: lag, partition, leader authority, quorum/availability trade-offs and fault exercise |
| Distributed state and transactions | Taught here | Build depth: local atomicity, conditional writes, outbox, duplicate/order handling and external gap |
| Resilience and fault tolerance | Taught here | Build depth: deadlines, bounded retries, circuit/probe, bulkheads, failover and recovery boundaries |
| Latency and performance | Taught here | Build depth: critical-path budgets, pool/queue/dependency waits and diagnosis |
| SRE and production operations | Taught here | Build depth: service indicators, error budget, incident roles, runbook, restore/failover evidence |
| Performance and incident diagnosis | Taught here | Build depth: symptom-to-boundary reasoning, traces, hypothesis and recovery checks |
| APIs and streaming protocols | Revisited from T18.2 | Build depth: lost response and minimum-version read; same operation identity |
| Backpressure and overload management | Revisited from T18.6 | Build depth: retry/probe limits preserve finite downstream capacity |
| Database architecture | Revisited from T18.2 | Design depth: transaction/constraint boundaries under injected failure |
| Caching systems | Revisited from T18.5 | Design depth: immutable body reuse does not become stale authority |
| Document ingestion and indexing | Revisited from T18.4 | Build depth: derived publication may lag but versions/tombstones remain authoritative |
| Enterprise retrieval governance | Revisited from T18.7 | Build depth: failover cannot silently widen policy freshness |
| Identity and access control | Revisited from T18.7 | Build depth: authority outage denies protected access, even when history can be read |
| Observability systems | Context only | T18.9, Build depth: use diagnostic signals now; version-aware telemetry architecture follows |
| Distributed architecture patterns | Deferred | T18.13, Design depth: no catalogue of unrelated architectures |
| Cloud networking and deployment | Context only | T18.12, Design depth: regional recovery needs a later deployment contract |
Outcomes: choose consistency per class; reproduce rollback/lost acknowledgement; reject false projection catch-up; bound recovery attempts; diagnose the latency path and write a verifiable recovery procedure. Prerequisites are the first six stages.
Key Takeaways
- A primary can acknowledge a write that a lagging replica does not yet hold. Reading that copy without a freshness requirement returns "not found" for an answer that is already durable.
- Reissuing generation with a new operation key can charge twice. After a lost response, the client cannot tell from the timeout alone whether the commit happened.
- Recovery rules depend on the data class, not on whether another server can respond. Serving protected context from a stale membership replica turns an availability fallback into an access regression.
- A circuit breaker limits attempts but does not repair the dependency or prove remote cancellation. A transactional outbox commits intent with local state, and its delivery can still repeat.