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 →
- Expand: add new columns or tables without removing old ones; use online DDL tools (
pg_repack,gh-ostfor MySQL) for large tables. - Deploy code that writes to both and reads the old.
- Backfill data in batches with throttling.
- Switch reads to the new schema behind a feature flag.
- After a stable period, stop writing old columns, then drop them in a later release.
- 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.
More on Releases & Reliability Patterns
A canary at 10% shows a 0.3% higher error rate than stable. Promote or roll back?IntermediateA downstream service is slow, and your service's retries are making it worse.IntermediateA feature flag was turned on for 100% of users and caused errors. How do you handle it and prevent recurrence?BeginnerYour service calls five dependencies sequentially, and total latency is too high.IntermediateA third-party API you depend on has rate limits, and you're hitting them during peaks.BeginnerA canary deploy passed analysis, but the full rollout caused errors at 100%.Advanced