liveBook · Manning

Parallel change

As explained in Grokking Software Architecture

A database migration pattern that introduces compatible schema changes in stages so old and new application versions can operate during a rollout.

Parallel change, also called the Expand/Contract Pattern, makes breaking database or shared API changes without downtime. Instead of replacing a shared structure in one risky deployment, it keeps old and new versions compatible while the change rolls out. section 13.4.3

Move through three backward-compatible phases:

  • Expand: Add the new schema alongside the old one; leave the legacy structure intact. section 13.4.3
  • Transition: Deploy code that reads the old path, writes both layouts, and backfills existing records. Protect concurrent writes with deterministic ordering or optimistic concurrency locks. section 13.4.3
  • Contract: Remove deprecated structures only after active service instances and data have moved to the new layout. section 13.12 section 13.4.3

Renaming a customer field

To replace customer_phone with phone_mobile, add the new column without deleting the old one. During transition, write both values; an orders insert can populate both columns. Without safe write ordering or concurrency control, an older service instance could overwrite migrated data. section 13.4.3

Figure 13.8 Expand/Contract Pattern: By breaking schema changes into a non-destructive sequence, you ensure backward compatibility and eliminate the risk of database-driven outages.

See how a non-destructive sequence preserves backward compatibility during a schema change. section 13.4.3

How Grokking Software Architecture covers it

How deep it goes
Explains three migration phases, dual writes, backfills, and concurrency risks.
Examples
Uses a customer_phone-to-phone_mobile rename and an orders insert that writes both columns.
What it assumes
Assumes a rollout may run multiple service versions at once and teaches the migration phases directly.
What you can do after
Operate a phased schema migration while old and new service versions remain active.
How it connects
Connects schema migrations with zero-downtime deployments, canary deployments, dual writes, and optimistic concurrency.

Also explained in

Compare how 2 books explain parallel change →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.