The interview problem

Practice prompt

Design recovery for a 2 TB transactional database. The business asks for at most five minutes of lost committed work, service restoration within two hours of an outage, and recovery to a selected point during the previous seven days. Handle accidental deletion, unavailable infrastructure and an incomplete backup archive. Explain how you would prove that recovery works.

Original system-design practice, not a reported company interview. Workload, timings and incident examples are hypothetical. Official PostgreSQL 17 references retrieved September 27, 2026.

1. Turn recovery objectives into testable contracts

Recovery point objective (RPO) limits the gap between the incident and recoverable committed state. Recovery time objective (RTO) limits elapsed time from service interruption to a defined usable service level. Here the clock includes detection, authorization, provisioning, data transfer, replay, validation and traffic cutover. Define that usable level explicitly: authenticated reads and writes at the agreed throughput, not merely a database process accepting a connection.

Separate disaster recovery from deliberate recovery before a bad transaction. If an erroneous deletion happened yesterday, restoring before it intentionally removes later database history too. A five-minute disaster RPO does not mean yesterday's deletion can be undone while automatically preserving every later legitimate transaction. Selective repair requires an additional reconciliation process.

Assume one database cluster with a coherent transaction log. Cross-service payment state, uploaded objects and messages require their own recovery contracts. A running replica can help an infrastructure failure, but it may faithfully reproduce an accidental deletion. Neither replica count nor backup job success proves the seven-day recovery promise.

2. Catalog recovery dependencies

database → consistent base backups → protected backup store
       ↘ ordered transaction logs → protected log archive
                                      ↕
                           recovery catalog + verifier
                                      ↓
                        isolated restore environment
                                      ↓
                         validation → controlled cutover

For a PostgreSQL-style design, a physical base backup and the required continuous WAL sequence support replay; a logical dump is not a substitute in that chain. Use a supported backup mechanism rather than an arbitrary live-directory copy. Preserve timeline history and separately manage configuration needed to start the recovered system.

The proposed catalog records database identity, engine/build requirements, backup ID, parent dependencies if any, start/end log positions, timeline, file hashes, encryption-key references and verification results. It distinguishes uploaded, structurally verified, restore-tested and expired states. A completion marker appears only after all required objects are durably available. Readers do not discover a backup by listing an unfinished upload directory.

Separate production write credentials from deletion authority over backups. Keep a recovery copy outside the primary failure domain and rehearse access without the primary identity service. Preserve compatible binaries, extensions, configuration and key-recovery procedures. An encrypted archive whose key is irretrievably lost is not a recovery option.

3. Track contiguous coverage, not the newest object

Imagine a valid base backup B with required log coverage beginning at position 100. Archived segments cover positions 100–160 and 170–220, but 160–170 is absent. The newest object ends at 220; B still cannot replay through the gap. Locate another intact copy or choose a recoverable earlier target. Do not silently skip log records and advertise a successful restore.

A separate valid base backup C whose required recovery range starts after the gap may allow later targets. It does not fill the inaccessible interval before C becomes recoverable. Model the recovery window as a set of supported intervals and dependencies rather than one minimum and maximum timestamp.

Assume commits continue through a hypothetical 12:00 outage. Suppose verification establishes that the latest recoverable commit is 11:42, even though objects labeled through 11:59 exist. Actual exposure is 18 minutes, violating the five-minute objective. Recovering another copy that extends verified coverage to 11:57 reduces that gap to three minutes. Establish commit coverage from database recovery evidence; object upload timestamps are not transaction commit times. An idle database with no newer commits does not lose work merely because its last commit is old.

Measure archive lag, gaps, failed verification, key access and the oldest supported target. Alert on the recoverable frontier. Segment completion, upload and queueing all contribute to lag. For example, a design budget of 60 seconds to close a segment, 40 seconds to transfer and persist it, and 20 seconds of queueing totals 120 seconds in the stated healthy scenario. It leaves 180 seconds within a five-minute objective, but does not bound a failed uploader's outage. An asynchronous design needs an explicit policy for prolonged loss of protection: stop admitting further writes, accept an RPO violation, or switch to another protected path. Stopping new writes limits further exposure; it does not make already acknowledged, unarchived commits durable elsewhere.

4. Work through a restore budget

Use decimal units and assume a full 2 TB must be transferred without compression. At measured end-to-end restore throughput of 500 MB/second, copying takes 2,000,000/500 = 4,000 seconds, or 66 minutes 40 seconds. Do not use the object store's advertised bandwidth when decompression, writes or network limits make the actual restore slower.

Suppose the selected target requires 240 GB of log replay, measured at an effective 200 MB/second including log retrieval and application. Replay takes 240,000/200 = 1,200 seconds, or 20 minutes. Budget another ten minutes for detection and provisioning, fifteen for integrity and application validation, and five for reopening traffic. With these sequential phases, total time is 116 minutes 40 seconds. Only three minutes 20 seconds remain under a two-hour RTO.

If restore throughput falls to 400 MB/second, copying takes 83 minutes 20 seconds and total recovery takes 133 minutes 20 seconds: the same archive misses the objective. Improve measured restore performance, reduce replay work with more frequent valid bases, maintain a prepared restore environment, or renegotiate the requirement. Parallel phases may reduce the critical path only when demonstrated; do not subtract overlapping time speculatively.

Log replay speed depends on workload and storage, not just log bytes. Repeat drills with large transactions, index changes and cold caches. Report the distribution of observed end-to-end times and worst tested conditions. One favorable exercise does not establish a guaranteed upper bound.

5. Retain the chain needed by the promise

At Monday 12:00, a rolling seven-day promise includes the previous Monday 12:00. If the available daily base before that target began at the previous Monday 00:00 and became recoverable before its 12:00 target, keep that base and its necessary log chain even though some objects are more than seven days old. Deleting everything by object age can break the oldest part of the promised window. Pin dependencies of retained targets and active restore jobs; release them through a catalog-aware garbage collector.

At a hypothetical sustained 10 MB/second of archive data, one day is 864 GB and seven days are 6.048 TB, before base backups, redundant copies or metadata. Eight uncompressed 2 TB bases add 16 TB. The resulting 22.048 TB is an illustrative lower accounting total for those objects, not a complete seven-day deployment estimate: boundary coverage may require additional logs, and real rates vary. Compression or incremental bases can save space while introducing different restore costs and dependency chains.

Deletion should have a grace interval and audit trail. A retention job must not delete an ancestor simply because a newer incremental backup exists. Protect against a compromised production principal deleting both data and recovery history, and test whether retention controls actually apply to every required object and key.

6. Restore safely and reconcile external effects

Declare an incident owner and target selection. Fence the old writer before admitting writes to the restored database; changing DNS alone does not prevent an old worker from continuing to write. Restore into an isolated environment with outbound email, billing and queue consumers disabled. Verify database identity, backup chain, timeline and the requested stopping boundary before promotion.

Validate structural integrity, important invariants and representative application operations. Check counts and totals against independent evidence when available. A database that starts successfully can still contain the wrong historical target or semantically bad application data. Record the exact recovered position and the known interval of lost or deliberately excluded work.

Suppose an order was dispatched externally at 11:58 but the database is restored to 11:57. Replaying a dispatch worker may ship it again. Reconcile stable business operation IDs against the fulfillment provider before enabling that worker. Database recovery does not roll back trucks, emails or external payments. Retain an auditable list of uncertain operations and route ambiguous cases for resolution.

After controlled cutover, begin and verify protection of the new history. Keep evidence needed to investigate the original incident. Do not delete the former primary merely because traffic now reaches the replacement; its surviving logs may be useful for reconciliation or recovering otherwise missing committed work.

7. Make restore drills part of the system

Run automated isolated restores against selected recent and boundary targets, plus periodic operator-led disaster exercises. Inject a missing segment, corrupt object, inaccessible key, unavailable primary account, insufficient disk and wrong engine extension. Verify both failure detection and the documented fallback. Sample restore tests reduce uncertainty but do not prove that every untested point is recoverable.

PostgreSQL's backup verifier checks backup contents against a manifest and can examine required WAL. Its documentation explicitly distinguishes these checks from the stronger confidence gained by actually restoring and exercising the database. Use both layers. Persist drill inputs, versions, selected target, phase durations, validation results and any manual interventions so an RTO claim can be reproduced.

8. Follow-ups and self-review

Follow-ups: Can a later backup bypass a missing earlier segment? Only for targets supported by that backup's own complete dependency chain. Does five-minute RPO guarantee zero lost transactions? No. Can you restore only one tenant with this physical mechanism? Restore an isolated cluster and build a carefully validated logical repair path; do not pretend cluster replay filters tenants. What if backup retention meets policy but keys expire earlier? The effective recovery window is limited by all required dependencies.

Score 0–2 each for precise RPO/RTO definitions, contiguous log and timeline reasoning, realistic recovery arithmetic, safe cutover and external-effect reconciliation, and evidence from destructive-failure drills. A strong answer names which guarantees fail when a dependency is missing and refuses to label an incomplete chain recoverable.

Sources and next steps

The service architecture, incident trace, capacity examples and review rubric are original exercises. Continue with distributed transaction recovery for uncertain commit decisions across participants.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.