linear.app · Free post · Execution, roadmaps & process · Metrics, data & experimentation

Post mortem on Linear incident from Jan 24th, 2024

LinearJan 30, 20249 min
Sourcelinear.app
KindFree post
PublishedJan 30, 2024
Originallinear.app ↗
N:

Linear experienced a five-hour data loss incident on January 24, 2024, caused by a database migration that accidentally deleted production data for issues, comments, notifications, and other entities. A CASCADE truncate operation removed far more data than intended, but the impact was hidden by multiple caching layers for 30 minutes. Linear restored 99% of data within 36 hours by replaying sync packets and identified systemic improvements needed in database access controls, migration review processes, and disaster recovery testing.

01Key takeaways

  • Separate database migrations from code review; require dedicated database admin approval for dangerous operations like CASCADE truncate.
  • Test disaster recovery procedures regularly; Linear had never tested point-in-time recovery, forcing slower full backup restoration.
  • Multi-layer caching can hide data corruption; monitor for sync conflicts and data integrity anomalies, not just error rates.
  • Replay logs (sync packets) enable recovery of user actions; maintain immutable audit trails of all mutations for disaster scenarios.
  • Restrict production database privileges; remove TRUNCATE and other dangerous operations from standard user roles.
  • Automate migration testing in staging to catch edge cases before production; reduce friction in the review process.

02Key sections

Incident Timeline and Scope
The faulty migration merged at 07:01 UTC and went undetected for 30 minutes due to client-side caching. Linear entered maintenance mode at 09:56 UTC, restored from a 04:47 UTC backup by 10:48 UTC, and completed full data recovery by January 26. The incident affected 12% of workspaces with unavailable data and 7% with missing automated changes.
Root Cause: CASCADE Truncate Misunderstanding
Engineers intended to delete data in new feature tables using TRUNCATE with CASCADE to remove test data with foreign keys. However, CASCADE deleted all rows in any table with foreign keys pointing to the target table, wiping production data across multiple critical tables. The dangerous operation was missed during code review and local testing.
Why Detection Was Delayed
Linear's multi-layer caching architecture (client cache, database cache, sync engine) masked the data deletion for 30 minutes. Deleted rows didn't generate sync packets, so clients continued serving cached data. Only when users mutated deleted entities did errors surface, first visible in the notification system due to its high update frequency.
Recovery Strategy and Challenges
Linear used its sync packet log to replay all changes made during the outage window. A restoration script reapplied actions per workspace, but conflicts arose: duplicate document content, users created during outage, and updates to deleted entities. The team manually investigated errors and recovered 99% of data, leaving 4,136 unrecoverable sync packets.
Systemic Improvements
Linear committed to removing TRUNCATE privileges from production database users, implementing separate database admin review for migrations, automating staging environment testing, and building point-in-time recovery tooling. Additional changes include data integrity monitors, read-only mode capability, and improved internal incident response tools.
“CASCADE simply truncates the entire contents of any tables that have foreign keys to the table.”Linear · linear.app
“Data caching was also one of the primary reasons the problem was missed in local development.”Linear · linear.app

03Frameworks mentioned

Summary and takeaways written by PM Atlas; quotes are short excerpts. © the original author.