Quick revision
The short answer
Restoring the live database to 07:59 would throw away six hours of valid orders, payments and status changes from 97 percent of customers to fix 3 percent, which costs far more than the bug; a full restore fits only when most data since the restore point is bad or lost. Instead we stop the damage by rolling back or disabling the faulty code path, find the affected rows precisely, restore a copy to 07:59 on a separate instance for comparison, and repair forward with a reviewed, idempotent correction or compensating events so downstream systems see the fix. Afterwards we add audit columns or an event log recording which release wrote each row and keep point-in-time retention long enough for late discoveries.
What to remember
In this answer, we saw that rewinding the live database to 07:59 would discard six hours of valid work to fix 3 percent of orders. The right recovery stops the damage first, finds the affected rows precisely with help from a restored side copy, repairs forward with a reviewed, idempotent script and compensating events so downstream systems stay consistent, and adds audit columns and longer point-in-time retention for next time.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Restoring the live database to 07:59 would throw away six hours of valid orders, payments and status changes from 97 percent of customers to fix 3 percent, which costs far more than the bug; a full restore fits only when most data since the restore point is bad or lost. Instead we stop the damage by rolling back or disabling the faulty code path, find the affected rows precisely, restore a copy to 07:59 on a separate instance for comparison, and repair forward with a reviewed, idempotent correction or compensating events so downstream systems see the fix. Afterwards we add audit columns or an event log recording which release wrote each row and keep point-in-time retention long enough for late discoveries.
Why this question is asked
Backups and point-in-time recovery are designed for losing data, but many real incidents are about wrong data: a bug that writes plausible but incorrect values for hours before anyone notices. The instinct to rewind the database is strong, because it seems to undo the bug. Interviewers ask this scenario to see whether we understand what a rewind would also undo, and how to repair data surgically while the business keeps running. In this answer, we will see why restoring to 07:59 is wrong, then walk through the recovery: stop the damage, find the affected rows, compare with a side copy, repair forward through normal channels, and prepare for next time.
1Why Restoring to 07:59 Is the Wrong Answer
A point-in-time restore of the live database would bring it back exactly as it was at 07:59. That removes the wrong totals, but it also removes every other write since then: six hours of new orders, payments, address changes, cancellations and shipment updates from the 97 percent of customers who were never affected. Payments taken by the provider would no longer match any order, shipped parcels would have no record, and customers would see their orders vanish.
So the cure is far worse than the disease. A full restore fits when most of the data written since the restore point is bad, or when data was lost or destroyed, such as a dropped table. For a bug that corrupted a small, identifiable fraction of rows, we repair those rows and leave the rest alone.
2Stop the Damage
Before any repair, the number of bad rows must stop growing. We roll back the release from 08:00, or, faster, turn off the faulty currency-conversion path with a feature flag if one exists. Every minute this waits adds new wrong orders and new downstream effects like refunds and invoices.
Notice that this step comes before the investigation is finished. We do not need to understand the bug fully to stop it; we only need to stop running the code that introduced it.
3Find the Affected Rows Precisely
Next we identify exactly which rows are wrong. The window is known, 08:00 to the rollback, and the condition that triggered the bug can usually be expressed in a query, for example orders in a foreign currency with a certain conversion path. If rows record which release or code version wrote them, the search is even more precise.
For comparison, we restore a copy of the database to 07:59 on a separate instance, not on the live one. That copy shows the state before the bug, such as exchange rates, prices and customer settings, which helps recompute the correct totals. Some teams also restore a copy to the current time to freeze the exact state being repaired.
4Repair Forward Through Normal Channels
The repair is a correction script, reviewed like code. It updates each wrong total to the correct one, records the old and new values in a correction table, and is idempotent, meaning running it twice has the same effect as running it once, so a partial run can be safely retried.
But changing rows silently is not enough. Refunds were already issued against the wrong totals, invoices were generated, and the warehouse may have used the values. If we only update the orders table, those systems keep their wrong copies. So the repair emits compensating events or uses the normal business operations, for example an OrderTotalCorrected event, an adjustment invoice, or a supplementary refund or charge, so every downstream system learns about the correction through the channels it already understands and keeps an audit trail.
6 messages in order. Play them, or step through them one at a time.
Downstream systems learn about the fix through their normal inputs.
5Prepare for Next Time
This recovery was possible because the bad rows could be found. To make the next one easier, rows should carry what repair needs: audit columns such as created_by_release and updated_at, or an event log that records every change with its source. With those, the query in step 2 is exact rather than a guess.
Point-in-time retention matters too. Corruption is sometimes discovered days or weeks later, for example at month-end reconciliation. If PITR retention is only 7 days, a bug found on day 10 cannot be compared against a pre-bug copy. Keeping 30 days or more of base backups and logs, or long-retention snapshots, gives the investigation the data it needs.
6Follow-up questions
How do you handle customers who were already refunded the wrong amount?
We treat it as a customer-facing business decision, not just a data fix. For customers who were refunded too much, many companies absorb small differences rather than ask for money back, and contact customers only above a threshold, because the cost of collection and the damage to goodwill outweigh the amount. For customers who were refunded too little, we issue the difference automatically with a clear message. Either way, the actions go through the normal refund and payment systems so finance can reconcile them, and customer support gets a list and a script before customers start calling.
When would a full restore be right?
When most data since the restore point is bad or lost, for example a migration that dropped or scrambled a core table, and the writes after it are few or can be replayed from another source such as an event log.
Should the correction run in one big transaction?
Usually not. Batches of a few hundred rows with progress recorded keep locks short and let the job resume after a failure, which the idempotent design allows.
7Conclusion
In this answer, we saw that rewinding the live database to 07:59 would discard six hours of valid work to fix 3 percent of orders. The right recovery stops the damage first, finds the affected rows precisely with help from a restored side copy, repairs forward with a reviewed, idempotent script and compensating events so downstream systems stay consistent, and adds audit columns and longer point-in-time retention for next time.
Open with
Restoring to 07:59 would remove the bad totals, but it would also erase six hours of valid orders, payments, cancellations and shipment updates from the 97 percent of customers who were never affected, and payments taken by the provider would no longer match anything.
Then, if they want more
That costs far more than the bug. A full restore only makes sense when most of the data since the restore point is bad or lost. So first I would stop the damage by rolling back the 08:00 release or turning off the conversion path with a flag, so no new bad rows appear.
Then I would find the affected rows precisely: the time window, the condition that triggered the bug, and ideally a column saying which release wrote each row. I would restore a copy of the database to 07:59 on a separate instance, not the live one, to compare values and recompute correct totals.
The repair is a reviewed, idempotent correction script that records old and new values, and instead of changing rows silently it emits compensating events or adjustment invoices, so refunds, billing and the warehouse learn about the correction through their normal channels.
Afterwards, I would add audit columns or an event log that record which release wrote each row, and keep point-in-time retention long enough, say 30 days, for corruption discovered late.
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 "Why is restoring the database to 07:59 the wrong answer, and how would you recover?": https://scrivio-interview-library.netlify.app/architecture/high-availability/dcc60e56b0/