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

Start free on Cariara · Coding problems · System design studio