Silent Data Corruption from an Off-By-One Migration
A database migration that ran successfully corrupted currency amounts for 6% of transactions due to a truncation error: amounts were converted with int() instead of being rounded.
Overview
A currency migration finished with no errors, and 11 days later reconciliation found $847,000 of revenue recorded short.
What happened
The payment platform stored money as integer cents. A migration converted a legacy float column, which held dollars with two decimal places, into that integer format. It passed every test environment and staging with a sample of production data.
The story has four beats.
- The migration passed its tests and a staging run with a production sample.
- The production run converted 14M rows in 22 minutes with zero errors.
- Eleven days later, the monthly reconciliation found bad amounts.
- The team recovered by replaying the event store.
Key concepts
- Floating point precision error
- Integer arithmetic for currency
- Migration dry run with comparison
- Event sourcing
Interview questions
- How do you safely run a data-transforming migration on a large production table?
Sign up free to read the full topic
More War Stories topics
- Internal DNS Cache Poisoning That Redirected API Traffic
- Malicious npm Package Exfiltrated Environment Variables at Build Time
- N+1 Query Pattern That Collapsed Under Load
- NAT Gateway Port Exhaustion Under Bursty Lambda Traffic
- Node.js Memory Leak That Required Daily Restarts
- Public S3 Bucket Exposed Customer PII for 8 Months
- Single-Region Dependency That Caused a Global Outage
- The Cascade That Took Down Three Services
- Third-Party API Outage That Was Mistaken for Own Code
- Thundering Herd After a Cache Cluster Restart
- TLS Certificate Expiry That Took Down an Internal API
Start free on Cariara · Coding problems · System design studio