The Bad Update Reached Every Replica. What Can We Restore?
Replication faithfully copies a mistake too. Recover a known snapshot through a complete log interval, then verify the recovered service before switching readers.
14 sections · 4 questions · 1 coding challenge
The arrow keys move between sections too.
Retaining an Earlier State After the Current Copies Change
BOTIE
The useful recovery idea is a boundary. A snapshot establishes a known earlier state; a valid replay interval brings that state to a chosen later point. The target must fall inside the history the backup system can actually recover.
Sources for this history
Every Copy Now Agrees on the Wrong Stock Balance
A faulty importer sets north’s stock to zero. Replication does its job and sends that change to the other copies. Botie can reach the service, but every reachable view now contains the mistake.
We need history from before the damage, not merely another current copy. A backup snapshot and retained changes can reconstruct a chosen state if their recovery contract covers the required interval.
Invented maintenance records. These deterministic local models expose a storage decision; they do not run a distributed database or establish its guarantees.
Step 1 of 1
Stop before the known bad change
This teaching log uses consecutive positions and full replacement values.
| Position | Operation | Use when restoring to 12? |
|---|---|---|
| 10 | Snapshot: north 8, south 2 | Start here |
| 11 | north becomes 5 | Replay |
| 12 | south becomes 5 | Replay |
| 13 | Faulty import makes north 0 | Stop before this |
10
- Operation
- Snapshot: north 8, south 2
- Use when restoring to 12?
- Start here
11
- Operation
- north becomes 5
- Use when restoring to 12?
- Replay
12
- Operation
- south becomes 5
- Use when restoring to 12?
- Replay
13
- Operation
- Faulty import makes north 0
- Use when restoring to 12?
- Stop before this
A recoverable point needs complete supporting history
The replay result follows the chosen target and refuses incomplete teaching history.
Restore the stock record before the faulty import
Check the replay interval, apply its replacements to a snapshot copy, then label the recovered state with its target position.
BOTIE
Recovered state and position
{
"seq": 12,
"state": {
"north": 5,
"south": 5
}
}Follow the operations
1. Backup snapshot
{ "seq": 10, "state": { "north": 8, "south": 2 } }2. Retained recovery log
[ { "seq": 11, "id": "north", "units": 5 }, { "seq": 12, "id": "south", "units": 5 }, { "seq": 13, "id": "north", "units": 0 } ]3. Chosen recovery position
12
4. Check the replay interval is complete
[ { "seq": 11, "id": "north", "units": 5 }, { "seq": 12, "id": "south", "units": 5 } ]5. Replay retained replacements into the snapshot
{ "north": 5, "south": 5 }6. Label the recovered state with its target
{ "seq": 12, "state": { "north": 5, "south": 5 } }7. Result
{ "seq": 12, "state": { "north": 5, "south": 5 } }
Consecutive positions and replacement records are a local teaching protocol. This is not a physical backup, restore guarantee or rollback of external effects.
1. Distinguish surviving a failure from undoing a mistake
Replicas can help keep a service running after a node fails. They commonly receive validly committed mistakes as well as intended writes. A backup protects a different need: recovering a previous state or a separate durable copy under its retention policy.
A backup on the same compromised account or storage boundary may share the incident’s failure mode. Choose isolation, retention and deletion controls according to the failures the maintenance service must recover from.
A healthy replica is useful, but it is not automatically a historical backup.
2. Define the recovery point and the recovery time
The recovery point objective describes acceptable data loss, often expressed as how far back the restored state may be from the incident. The recovery time objective describes how long the service can remain unavailable or degraded while recovering. These are requirements, not outcomes established by enabling a setting.
Measure both in restore drills. Include locating the backup, obtaining authorised keys, restoring data, checking application configuration and making the service usable. A quick file copy can be a small part of the complete recovery time.
The exercise’s target sequence illustrates a chosen point, not a measured RPO or RTO.
Check yourself
Questions on Parts 1 to 2
Question 1 of 2
Which source can support historical recovery?
Use the information below.
A bad committed stock update has reached every replica. A backup exists from before it.3. Check that the replay interval is complete
Our teaching snapshot contains seq and a dictionary of inventory balances. Each log record gives the next consecutive sequence and a full replacement for one balance. To restore a target, select positions after the snapshot up to that target and require every intervening position.
A missing event stops the operation. Publishing the remaining records would create a plausible image whose history is incomplete. Real recovery logs may have gaps in numeric positions, so their completeness checks use the database’s documented mechanism rather than this invented consecutive-integer rule.
The local function is a deterministic restore calculation, not a database backup tool.
Inspect the required replay positions
The target lies after the snapshot and before a later faulty update.
snapshot_position = 10
target = 12
required = list(range(snapshot_position + 1, target + 1))
print(required)
print(13 in required)[11, 12]
FalseThe later operation is excluded because it is outside the selected recovery interval.
4. Replay into a separate state and verify the result
Copy the snapshot before applying changes so a failed attempt does not destroy the starting point. Replaying full replacements in sequence gives the state at the target under this fixture’s contract. A new key can appear in the replay even if the snapshot did not contain it.
After recovery, compare expected identities and balances and run application-level checks. Restoring bytes is not proof that indexes, access policies, credentials and application configuration are ready. Some services restore into a new resource that needs its settings reapplied.
DynamoDB documents restoration into a new table and lists settings that need separate attention.
5. Protect backup access and the keys needed to read it
Backups can contain the same sensitive tenant data as the live service. Restrict who can list, read, restore or delete them. Use the supported encryption mechanism and retain access to its keys for the entire recovery period. A perfectly intact encrypted backup is unusable if the recovery team cannot obtain the required key permissions.
Use separate development restore destinations and appropriately scoped roles during drills. Verify that a restored copy does not accidentally expose production data through a broadly accessible test service.
Recovery permissions should allow the planned procedure without becoming ordinary web-application privileges.
6. Decide what happens to legitimate work after the target
Restoring before the faulty import can also remove legitimate changes that happened afterward. Identify which later operations can be safely replayed, reconciled or re-entered. Keep evidence of external actions, such as deliveries already dispatched, because moving the database backwards does not undo them.
Freeze or route writes during cutover according to a documented plan. Otherwise the old and restored services can both accept new stock changes and diverge while the team believes recovery is complete.
Choosing a point is a business recovery decision as well as a storage operation.
7. Prove the procedure before the incident
Run a restore drill with representative size and application checks. Record which backup was used, its recoverable interval, the measured elapsed time and any settings that were missing. Test a missing-history case so the process refuses an unsupported target.
Repeat after material schema, encryption or infrastructure changes. A recovery document that nobody has exercised can preserve an obsolete assumption for months.
The workshop’s later target includes the faulty change deliberately. Inspect the target before treating a successful replay as the desired repair.
Check yourself
Questions on Parts 1 to 7
Question 1 of 2
What should the restore function do?
Use the information below.
Snapshot position is 10, target is 12, and the teaching log contains only position 12. Positions are defined as consecutive.Try it with Botie
Build with Botie
Write and run Python