Diagnose inconsistent data in a distributed database
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Google's system design round, last asked Sep 2025. It tests replication, debugging and sre.
Users report reading different values for the same record from a replicated distributed database. You are on call. List the likely causes, then give a step-by-step investigation: what telemetry and logs you check, how you verify which consistency guarantees still hold, and how you mitigate the incident, repair the data and prevent a repeat. Discuss the consistency, availability and latency trade-offs you make while the incident is live.
Requirements
- Functional: find the cause, stop new inconsistencies, repair the diverged records, and prove the repair worked.
- Non-functional: keep the service available while investigating where possible; never lose acknowledged writes; leave an audit trail of every manual change.
Clarifying questions
- Is the database leader-based (Raft, Paxos, primary-replica) or leaderless (quorum, Dynamo-style)?
- Which consistency level do clients use for reads and writes?
- Is the inconsistency temporary (stale reads that converge) or permanent (replicas that never agree)?
- Did anything change recently: a deploy, a config change, a failover, a network event?
- How many records and which regions are affected?
What a strong answer covers
- Causes: replication lag and reads from followers; read and write quorums that don't overlap (
R + W <= N); a failed or flapping leader election, or split brain without fencing; clock skew breaking last-write-wins; network partitions; concurrent writes without conflict resolution; anti-entropy or repair jobs that stopped; application bugs such as caching or writes that skip the database. - Investigation order: scope (which keys, replicas, regions, since when), correlate with changes and failovers, then check replication lag metrics, election and term logs, NTP offset per node, quorum settings in client configs, and repair job status. Compare replica values and version vectors or timestamps for affected keys.
- Verifying guarantees: targeted read-after-write tests, quorum reads compared with single-replica reads, and a consistency checker over a key sample.
- Mitigation: route reads to the leader or raise read quorums, fence the stale leader with epoch or token checks, fix clock sync, throttle writes during repair. Each step's cost in latency or availability, stated and decided.
- Repair: run anti-entropy (Merkle-tree comparison), backfill from the source of truth or the write log, resolve conflicts with a clear rule, and verify afterwards.
- Prevention: alerts on lag, election churn and clock offset, continuous consistency checks, and a postmortem.
Follow-ups
- Two replicas each accepted different writes during a partition. Which value wins, and who decides?
- How would you build a continuous checker that finds divergence before users do?
- The fix needs a full repair of petabytes. How do you run it without hurting production traffic?
Where it's asked
- Google · System design · Last asked Sep 202545 min · Whiteboard for the diagram, a doc for requirements and capacity math
What it tests
replication · debugging · sre
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
