HomeRoadmapsDB Migration Day 6
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.

⚑ Runtime: Node.js 22 LTS Β· VitestπŸ›‘οΈ Database Reliability & Schema Evolution QE Architect
πŸ“¦Sample Codebase & Working Solution (Day 6)Available Now
View on GitHub

The 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:day6
Step 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?