Scrivio Interview library
ScenarioAdvanced6 min read · updated 13 November 2026

The primary database of an order platform failed. Failover was meant to take a minute, but took four hours: the standby was six hours behind because replication had silently stopped, and the failover runbook required a bastion host in the failed zone.

What went wrong with the redundancy, and how would you make sure the standby really works the next time?

The redundancy existed only on paper: replication had silently stopped six hours earlier, nobody was alerted, and the failover runbook depended on a bastion host in the zone that failed. To make the standby really work, we monitor replication health and lag with alerts within minutes, treat a broken standby as an incident, keep failover tooling and access outside the failure domain, practise failover regularly and measure it, automate the steps that work, and make sure the standby and the remaining zones can carry full load.

Why this question is asked

Most teams that suffer a long database outage did have a standby. What they did not have was evidence that the standby worked. This incident combines two classic failures, silent replication breakage and a recovery path that depended on the thing that failed, and turned a one-minute event into four hours and probably some lost or delayed orders. Interviewers ask about it to see whether we treat redundancy as something we verify continuously rather than something we install once. In this answer, we will break down what went wrong, then go through monitoring, removing dependencies on the failed zone, regular failover practice and capacity checks, with a decision on automated versus manual promotion.

1What Actually Went Wrong

Two separate failures lined up. First, replication from the primary to the standby had stopped six hours before the incident, perhaps because the standby fell too far behind and the primary recycled write-ahead log segments it still needed, or because a network or credential change broke the connection. Nothing alerted, so the standby looked healthy in the inventory while holding data six hours old.

Second, the runbook required logging in through a bastion host that lived in the failed zone. So when the primary failed, the team first had to find a way in, then discovered the standby was six hours behind, then had to decide whether to promote a stale database or recover the primary's data. Each step took time, and together they took four hours.

Assumed versus actual redundancy
AssumptionReality on the dayFix
The standby is currentsix hours behind, replication stoppedlag and status alerts within minutes
Failover takes a minutefour hoursregular timed failover drills
The runbook worksneeded a bastion in the failed zonetooling and access in other zones
The standby can take the loadnever tested at peaksame size, headroom in remaining zones

2Monitor Replication and Treat a Broken Standby as an Incident

The standby must be watched as closely as the primary. In PostgreSQL, the primary's pg_stat_replication view shows each connected standby and how far behind it is, and the standby can report the time since the last replayed transaction. We export these as metrics and alert when the standby disappears from the view, when replay lag exceeds a bound such as 30 seconds, or when lag keeps growing.

SQL
-- on the primary
SELECT application_name, state, replay_lag
FROM pg_stat_replication;
-- standby1 | streaming | 00:00:00.4 healthy
-- (0 rows) replication stopped: page someone
-- on the standby
SELECT now() - pg_last_xact_replay_timestamp() AS behind; -- 06:02:11 during the incident
-- note: on an idle primary this grows even when healthy, so pair it with a heartbeat write

A broken standby means we have lost our protection, so it should page someone and be handled as an incident, not a ticket for next week. Replication slots prevent the primary from removing log segments a standby still needs, but they let disk fill up if a standby is gone for long, so slot size needs an alert too.

3Keep Recovery Paths Outside the Failure Domain

A failure domain is the set of things that fail together, such as a zone. Anything we need to recover from a zone failure must not live in that zone. That includes the bastion host or access path, the failover tooling, the credentials and secrets it uses, the runbook itself, and the monitoring that tells us what happened.

In practice, we provide access paths in at least two zones or use a managed access service that is regional, keep failover scripts in a repository and runnable from a laptop or CI in another zone, and store runbooks somewhere that does not depend on the failed systems. Managed databases with multi-zone failover remove most of this, because the provider promotes the standby and moves the endpoint without our access.

4Practise Failover and Measure It

Redundancy that is never exercised decays. I would schedule a real failover in production, during low traffic, for example once a quarter, and measure each step: time to detect, time to decide, time to promote, time until applications reconnect, and any data lost. The first drill will find surprises, like connection pools that never reconnect or DNS caches that keep the old address, and that is exactly the point.

Steps that work reliably in drills should then be automated, using the database platform's failover or a tool such as Patroni, so the next real event follows the same path as the practice.

Step throughA quarterly failover drill
  1. Check lag is near zero and announce the window
  2. Fail over to the standbyrecord time to promote
  3. Verify applications reconnect and writes succeedrecord time to recover
  4. Run at full traffic on the new primarywatch latency and CPU
  5. Rebuild the old primary as the standbyconfirm replication is streaming
  6. Write up timings and fix what was slow

6 steps in order. Play them, or step through them one at a time.

5Check That the Standby Can Carry the Load

Failover can succeed and the system can still go down a few minutes later if the new primary is too small, or if the remaining zones cannot absorb the application traffic that moved to them. The standby should be the same size as the primary, with the same configuration and extensions, and the application tier should have enough headroom that losing one zone's servers still leaves capacity for peak. The drills at full traffic are what prove this.

6Follow-up questions

How do you decide between automated and manual promotion for this database?

Automated promotion gives the shortest outage, but it can make things worse if the detector is wrong: a network blip can cause a failover that was not needed, or, without proper fencing, two primaries accepting writes. Manual promotion is safer for judgement calls such as a standby that is behind. A common middle path is automation with guards: promote automatically only when the standby's lag is below a small bound and the old primary is fenced, otherwise page a person with a one-command runbook. Managed services and tools like Patroni implement these guards with a consensus store.

The standby was six hours behind: would you promote it?

Only after comparing the cost of losing six hours of orders with the cost of waiting. Usually the better path is to try to recover the primary's write-ahead log or disk, and promote only if that fails, then reconcile the missing orders from other sources such as payment provider records and event logs. That is a business decision the runbook should prepare in advance.

Would synchronous replication have helped?

It would have made the problem visible sooner, because with a synchronous standby required, writes block when replication breaks. But that turns a standby failure into a primary outage, so it needs at least two standbys or a quorum. Monitoring and drills are needed either way.

7Conclusion

In this answer, we saw that the redundancy failed because replication stopped silently and the runbook depended on the failed zone. We make the standby real by monitoring replication status and lag with paging alerts, treating a broken standby as an incident, keeping tooling, credentials and access outside the failure domain, practising failover regularly and automating what works, and confirming that the standby and remaining zones can carry full production load.

What to say in the interviewAbout 70 seconds aloud

Open with

The redundancy was assumed, not verified. Replication had silently stopped six hours earlier, so the standby was stale, and the runbook needed a bastion host in the very zone that had failed, so a one-minute failover became four hours.

Then, if they want more

To make sure it works next time, I would first monitor replication continuously: export replication state and replay lag from pg_stat_replication and the standby, alert within minutes when the standby disconnects or lag grows, and treat a broken standby as an incident because we have lost our protection.

Second, I would remove every dependency on the failure domain: access paths, failover tooling, credentials and runbooks must be available from other zones, or we use a managed database whose provider handles promotion.

Third, I would practise failover in production during low traffic, say quarterly, measure each step, fix what is slow and automate the parts that work, with guards such as only promoting automatically when lag is small and the old primary is fenced.

Finally, I would check capacity: the standby must be the same size as the primary, and the remaining zones must have headroom for full load.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What went wrong with the redundancy, and how would you make sure the standby really...": https://scrivio-interview-library.netlify.app/architecture/sd-fundamentals/8651c721e0/