Interview Prep/SRE & Reliability/Releases & Reliability Patterns

You need to roll out a risky database schema change with zero downtime.

AdvancedScenarioReleases & Reliability Patterns
Answer

Situation read → Schema changes are hard to roll back. Use expand/contract and backward-compatible steps.

What I'd do →

  1. Expand: add new columns or tables without removing old ones; use online DDL tools (pg_repack, gh-ost for MySQL) for large tables.
  2. Deploy code that writes to both and reads the old.
  3. Backfill data in batches with throttling.
  4. Switch reads to the new schema behind a feature flag.
  5. After a stable period, stop writing old columns, then drop them in a later release.
  6. Test each step on a production-sized copy.

Why → Each step is reversible, so a bad step does not cause an outage.

Interview tip → "Expand, migrate, contract" with rollback at each step.

All SRE & Reliability questions

More on Releases & Reliability Patterns