Accidental DELETE Without a WHERE Clause in Production
An engineer running a cleanup script against the wrong environment deleted 2.3 million user preference records in 4 seconds.
Overview
A cleanup script meant for staging ran against production because of a typo in an environment variable, and hard-deleted 2.3 million rows in 4.1 seconds.
What happened
The task was routine: delete soft-deleted user records older than 90 days from the staging database. The engineer had run the same script dozens of times. This time the DSN variable had a typo, so it fell back to the default, which was the production connection string set in the shell profile.
The incident moved in four steps.
- The script started with the mistyped DSN variable.
- In 4.1 seconds it deleted 2.3 million rows from user_preferences in production.
- A health check failed because it found zero preference rows.
- Recovery began, and it took 6 hours 12 minutes.
Key concepts
- RTO (Recovery Time Objective)
- RPO (Recovery Point Objective)
- Binary log replay
- Point-in-time recovery (PITR)
- Soft delete
Interview questions
- An engineer accidentally deleted 2 million rows from production. Walk me through the recovery.
- What is the difference between RPO and RTO, and how do backup strategies affect them?
Sign up free to read the full topic
More War Stories topics
- A Deployment That Could Not Be Rolled Back
- A Failed Migration That Left the Database in a Partial State
- A Feature Flag Change That Triggered a Production Outage
- An IAM Misconfiguration That Let a Developer Become Admin
- AWS Credentials Committed to a Public GitHub Repository
- Backups That Were Never Actually Completing
- BGP Route Leak That Rerouted Traffic Through an Unexpected AS
- Blue-Green Deployment That Resulted in Split-Brain Sessions
- Cache Stampede on a Flash-Sale Product Page
- Connection Pool Exhaustion That Brought Down 12 Microservices
- DynamoDB Hot Partition That Throttled a Flash Sale
- Failover to a Lagging Replica Lost 4 Minutes of Orders
Start free on Cariara · Coding problems · System design studio