The database disk was wiped mid-sale. Not one order went with it.
The same load as the payment test runs again. At second 50 Postgres is killed and its data disk deleted. Pick a backup method and see how long the shop takes to recover and how many orders are saved.
Backup method
Recovery, seconds13.8
Data lost, seconds21.4
Paid lost2,439
Lost in the end0
Archive every 30 seconds
The last WAL archive left 21.4 seconds before the disk was lost. Backup plus archive brings the books back only to that point. 2,439 paid orders are missing. The shop then refills the books from its record in Redis in 1.9 seconds, and the gap drops to zero.
From the crash to complete books
- Disk deleted2.3 seconds
- Copy backup5.0 seconds
- Replay WAL archive6.5 seconds
- Refill from Redis1.9 seconds
Paid orders recorded in the books
Show the technical side
| Archive every 30 seconds | Postgres default settings | pgBackRest, archive every 30 seconds | |
|---|---|---|---|
| archive_timeout | 30 s | 0 s | 30 s |
| Full backup before the sale | 1.7 s, 7.8 MB | 1.6 s, 7.8 MB | 5.2 s, 7.8 MB |
| RTO: crash to accepting writes | 13.8 s | 10.2 s | 10.9 s |
| WAL lost with the disk | 21.4 s | 52.2 s | 21.1 s |
| Lost with backup alone | 2,784 orders, 2,439 paid | 6,187 orders, 5,168 paid | 3,357 orders, 3,320 paid |
| Redis stream replay | 1.9 s | 2.0 s | 1.7 s |
| Lost after replay | 0 | 0 | 0 |
| Ledger afterwards | balanced, revenue matches | balanced, revenue matches | balanced, revenue matches |
- The shop keeps selling while Postgres is down. Stock and orders live in Redis, and the worker retries writes with backoff until Postgres is back.
- What the worker cannot save on its own are messages acknowledged before the crash that only partly reached the archive. Those come back through
worker -isi-ulang, which replays the stream. - The zero-loss result depends on Redis: the stream is not trimmed, and Redis writes its AOF every second to another disk. If Redis and Postgres are lost together, only the backup and archive remain.
- pgBackRest 2.60.0 takes about three times longer to back up (manifest, per-file checksums, zstd compression), but adds
verify, retention, and incremental backups. - An RPO near zero without Redis needs a replicated standby. That belongs to the resilience experiment.