Database Migrations & Zero-Downtime Schema Evolution Β· Day 6 Β· 20 min
Point-in-Time Rollback & Compatibility Chaos
Zero-Downtime Schema Evolution β Day 6
Inject mid-migration faults (lock_timeout exceeded, partial backfill abort, stale N-1 writer) and verify automated rollback preserves 100% of committed writes.
π¦Sample Codebase & Working Solution (Day 6)Available Now
View on GitHubThe official reference codebase for Day 6 is hosted in the repository. Clone the repository and navigate to tests/day6-rollback-chaos.spec.ts to run the working solution.
Git Clone β Working Solution
git clone https://github.com/777abhi/db-migration-qe-roadmap.git
cd db-migration-qe-roadmap/tests/day6-rollback-chaos.spec.tsπProduction Context & Enterprise Implementation
π‘ Why We Are Doing This: A rollback that drops a newly populated column or breaks N-1 pods turns a recoverable deployment into a permanent data-loss incident.
π’ Real-World Production Usecase: Chaos-testing migration rollbacks under active dual-write traffic and stale pod writes.
βοΈ How Implemented in Production: Fault-injection harness testing LOCK_TIMEOUT_EXCEEDED, PARTIAL_BACKFILL_ABORT, and STALE_N_MINUS_1_WRITER with 0 lost writes.
Phase 1
Run Rollback Chaos Verification Tests
Step 6.1: Run Day 6 Tests
Terminal β Day 6 Lab
npm run test:day6Step 6.2: Sample Codebase & Working Solution (Day 6)
src/rollback/rollbackChaosEngine.ts
const phaseAtFault = sim.getPhase();
sim.transitionTo('ROLLED_BACK');
for (const id of expectedIds) {
const row = sim.readAsNMinus1(id);
if (row.name.length > 0) preserved++;
else lostWrites++;
}Day 6 Key Learnings
- Simulated LOCK_TIMEOUT_EXCEEDED and PARTIAL_BACKFILL_ABORT mid-migration.
- Verified dual-write keeps N-1 and N columns synchronized even under stale N-1 pods.
- Asserted 0 lost committed writes and full N-1 read/write compatibility post-rollback.
π§ Knowledge Check
Why must dual-writing continue during SWITCH_READS until all N-1 pods are terminated?