Chapter 03 established the consistency rules: one authority per key, replication flowing away from it, and a fenced flip that the stores enforce rather than the routers. This chapter is about executing that flip on a real system with real people: what a traffic percentage actually exposes, what a ramp can and cannot detect, why the switch is a distribution rather than an instant, where the point of no return sits (almost always earlier than the plan says), how to decide on rollback in the first ten minutes, and a runbook built around an abort deadline instead of a hopeful timeline.
Every cutover plan has a dial, and nearly every plan reports it as a percentage of requests. That number is almost meaningless for a stateful migration, because the harm is counted in users, tenants and records, not requests. If routing is decided per request with probability p, a user who makes k requests in a session touches the new system with probability 1 − (1 − p)^k. At a 1% dial, a session of 50 requests has a 39% chance of having been served by new at least once. At 5% it is 92%. The “1% canary” has quietly exposed most of your active users, and worse, it has bounced them: request 12 read from new, request 13 from old. Every cache, every read-your-writes assumption and every pagination cursor now spans two systems with different lag and possibly different sort stability.
The fix is to make the routing key the unit of harm, and to route by a stable hash of it: hash(tenant_id) mod 10000 < dial. This has three properties per-request routing lacks. Exposure equals the dial (the green line). Growth is monotone, so raising the dial only ever moves units from old to new and never back, which means a unit crosses the boundary exactly once. And the exposed set is enumerable, so when something goes wrong you can list who was affected instead of estimating it from a percentage. One trap survives the switch to hashing: if each service evaluates the dial itself, with its own flag SDK, salt or cache of the flag value, a single request chain can be “in” at the API tier and “out” at the worker, which is per-request bouncing again, one layer down. Make the cohort decision once, at the edge, and propagate it (a header or trace baggage) so every hop agrees, and make the flag service’s hash salt part of the migration’s config so a “harmless” flag-SDK upgrade cannot reshuffle the cohort mid-ramp.
The harder question is which unit. Tenant-level routing gives clean blast radius and a natural list of affected customers, but tenants are wildly unequal. A dial of 10% of tenants might be 2% of load or 40%, depending on whether the hash happened to land on a whale. Route by tenant, but report the dial in load-weighted terms and place the whales by hand, late and alone. For a migration keyed by entity rather than tenant, the unit must be the transaction closure: the set of rows that one business operation touches together. Route orders by order_id when a refund reads the order, its payments and its shipment, and those are keyed differently, and a refund whose order moved while its payments did not becomes a cross-system join at the worst moment. The slicing rule from chapter 01 (queries must not cross slice boundaries) applies to the traffic dial too.
Architect's note · the first cohort is chosen, not sampled
The canary statistics in the SRE / Reliability track (Blast Radius: Cells, Shuffle Sharding & Safe Change) apply here unchanged. Distinguishing a 0.1% error rate from 0.2% needs about 23,500 requests in each arm, and the requirement scales as 1/Δ². The migration-specific consequence is sharper. Invert the formula and ask what the smallest extra error rate is that an aggregate SLI can detect at a given dial and dwell. On an illustrative service at 2,000 rps with a 0.1% baseline, a 24-hour dwell at 1% detects an extra error rate of roughly 1e-4. At 100% it detects roughly 1e-5. A translation bug that corrupts one response in a million is below the line at every dial, for any dwell you would accept; one in 100,000 is borderline even at 100% for a full day. And that is the optimistic case, because it assumes the bug produces an error. A mis-translated field returns HTTP 200 with a well-formed body. Its contribution to the error-rate SLI is zero at any volume, so the true detection floor for silent corruption is not 1e-5 but “never”.
That is the real division of labour, and most ramp plans get it wrong. The dial catches big-and-common failures: latency, capacity, a broken endpoint, a crash loop. It is structurally blind to small-and-rare correctness failures, and those are the failures migrations actually produce: a mis-translated enum on 0.3% of rows, a timezone bug on accounts created before 2015. Those are found only by comparison. Per-stratum shadow diffs (chapter 03) and at-rest reconciliation (chapter 05, Verifying Data You Cannot Eyeball) have a signal of exactly zero on healthy data, so a single mismatch is visible at any volume. Holding the dial at 5% for a week “to be safe” buys almost nothing for correctness. What it does buy is calendar coverage: month-end, the weekly batch, the cron job, the token expiry. Set dwell by the longest periodic cycle you need to observe, and set the number of steps by the capacity argument below.
The last doubling is a load test you did not run. Latency is nonlinear in utilisation. In an M/M/1 approximation, queueing delay scales as ρ/(1−ρ). A new system that ran at 45% utilisation at the 50% step sits at 90% at 100%, and its queueing delay rises about elevenfold (0.82 to 9), with nothing in the 1–50% steps predicting it. Connection pools, lock contention on hot rows and cache working sets all have cliffs of the same kind. Meanwhile the old system is getting less loaded, so any comparison of new against old at the 50% step flatters new. Either load-test new at 100% plus headroom before the ramp, with replayed traffic or a synthetic mirror, or make the last steps small: 50, 65, 80, 90, 100, each held through a daily peak.
1−(1−p)^k
users exposed, per-request routing
~1e-5
smallest detectable extra error rate at 100%, 24 h (illus.)
×11
M/M/1 queueing delay, ρ 0.45 → 0.9
1 cycle
minimum dwell: longest periodic job
A runbook line that says “flip flag, cutover complete” describes the control plane. The data plane moves when the last holder of the old route lets go, and those holders have tails ranging from seconds to months. Config pollers pick up the change within their poll interval. DNS-routed clients honour the TTL, plus whatever their resolver and runtime add on top; JVMs configured to cache lookups forever (historically the behaviour under a security manager) move only when restarted. Pooled connections stay on the old endpoint until they are recycled, and a pool without a maximum connection lifetime, or an HTTP/2 or gRPC channel that never receives a GOAWAY, will hold the old path for days. The batch job that started at 01:00 with a six-hour scan keeps its cursor on old until it finishes. Mobile builds and partner integrations with a hard-coded endpoint move on the upgrade curve, which never reaches zero.
Three consequences follow. First, the completion criterion is a measurement, not an action: old-side requests per caller, attributed with the caller identity you instrumented in phase 0 (chapter 01), must read zero, and the residual tail after the flip is the most accurate list of unknown callers you will ever get. Second, enforce at the server, then let clients follow. Chapter 03 applied this rule to writes with a fence. It applies to reads too: once the drain window has passed, have old actively close connections (a GOAWAY, a pool-kill, a revoked grant) so stragglers fail loudly and reconnect via the new route, instead of silently reading data that stopped being authoritative an hour ago. Third, synchronised reconnection is a thundering herd. If 400 pods each open a 20-connection pool against the new database within the same second, that is 8,000 connection attempts arriving together. Postgres ships with max_connections = 100, and even behind a pooler the TLS handshakes and auth lookups arrive as one spike. Stagger the flip by pod (jittered poll intervals), pre-warm pools on new before routing to it, and check the connection budget on new as a precondition of the flip step, not as a post-mortem finding.
Pitfall · caches are a second copy of old
Plans name a point of no return: usually “stop reverse replication” or “decommission old”. That is the declared PONR. The effective one is defined differently: rollback remains possible only while old can reach a state consistent with everything the outside world has already observed. The outside world includes users, but also emails, webhooks, payment processors, partners’ databases, downstream Kafka consumers and the warehouse. Chapter 01 covered the slow erosion of reversibility over the window. The point here is how quickly the first doors close on cutover day if you do nothing, and that most of them can be deliberately moved later.
Door
Push it later by
Identifiers leave the building
mint in old's format / a range old accepts
Outbound side effects (email, webhook, charge)
outbox with a release delay ≥ decision window
Downstream consumers commit new-shaped events
compat projector emits old-shaped events
New-only states written
features gated on the phase enum
Old fleet capacity, certs, on-call memory
keep warm; rotation stays pointed at old
Reverse sync stopped
the declared PONR
Take the second row. The new path sends an order-confirmation email at T+3 s. If you roll back at T+20 min, old has no record of the order that the email confirmed. You can reverse-sync the order row, but only if it is representable, and you cannot un-send the email. The mitigation is a design pattern, not a runbook step: route all externally visible side effects of the new path through an outbox with a release delay longer than your first decision window. Hold webhooks and non-urgent notifications for 30–60 minutes during the first hours of each slice’s cutover. If you roll back, discard or reconcile the held set; if not, release it. Customers see a delay, not a contradiction. Payment captures are the hard case, because you often cannot delay them. For those, make the new path call the processor with the same idempotency keys old would have used, so a rolled-back old path retrying the operation converges instead of charging twice. Check the processor’s key retention before relying on this: Stripe, for example, documents that keys may be pruned once they are 24 hours old, so the protection covers a same-day rollback, not a rollback in week three. Beyond that horizon, deduplication has to come from your own ledger. The Money & Ledger Systems track covers idempotency-key design in depth.
The third row is the one teams discover in production. New publishes change events in its own schema, and within a minute the search indexer, the fraud model and the warehouse have committed them. Roll back and those consumers now hold facts the authoritative system cannot explain. Run a compatibility projector for the whole window: new emits old-shaped events on the old topics, and new-shaped topics are published but unconsumed until the window closes. It is duplicate work, and it is the only way the downstream estate stays on the reversible side of the door.
Decision rule · write the door list before the date
The incident-command reasoning in the SRE / Reliability track (mitigate before you diagnose, whenever the mitigation is cheap and reversible) holds for route-back of reads. It breaks for migrations as soon as writes are involved, because reverse replication is also a contamination channel. Suppose new has been writing wrong values for twenty minutes: a mis-mapped status, a truncated field. Reverse CDC has already faithfully copied them to old. A fenced flip back puts you on an authoritative system that contains the same corruption, now with less observability and a team that has not operated it in a month. You have rolled back the code path and kept the damage. That is why the first question on the bridge is not “is it broken?” but “has the new side persisted anything wrong?”
impact growing
impact stable / contained
data correct (reads / latency / availability)
Route back now
Latency, errors, capacity, a broken endpoint. Nothing wrong has been persisted. Rollback is cheap and reversible; do it before diagnosing.
no bad writes · impact growing
Hold the dial, fix forward
Contained, understood, not getting worse. Oscillating the dial costs cache warmth and read-your-writes; a known small problem beats a fresh flip.
no bad writes · impact stable
new side persisted wrong data
Freeze writes on the slice, then decide
Fail closed first. Pause reverse sync so old stays a clean image of T-detect. Routing back now would ship the corruption to old and serve it from there.
wrong writes · impact growing
Stop the path, repair by key
Disable the endpoint or feature that writes wrongly, fix forward, and repair from a list of affected keys built from the write log, not from a guess.
wrong writes · impact stable
The bottom-left cell is where instinct fails. When writes are wrong and spreading, the first move is to fail closed on the affected slice: stop accepting writes, via the same fence mechanism as the flip, and pause reverse sync so that old remains a clean image of the system as it was at the moment of detection. Both actions are cheap and reversible, and they turn an expanding incident into a bounded one. Only then decide between flipping back (after repairing old from a key list) and fixing forward. The key list is the asset that makes either option tractable. It is derivable only if every write on the new path carries a migration-phase tag and a code version in its change log, so that “all rows written by build 4.12 between 14:02 and 14:23 on slice A” is a query, not a forensic project.
The uncomfortable arithmetic is that detection is slower than replication. Reverse CDC copies a bad row to old in seconds; the thing that notices the row is wrong is a shadow diff or a reconciliation pass (chapter 05) that runs on a cadence of minutes. With illustrative numbers, a slice taking 300 writes/s with a mapping bug on 2% of them produces 6 bad rows/s; if the reconciler runs every 10 minutes and the bridge takes 3 minutes to freeze, roughly 5,400 bad rows exist on new and, with a 2-second reverse lag, on old too. Pausing reverse sync at the freeze protects nothing that has already crossed. The fix is to make reverse lag deliberate: apply the reverse stream with a fixed delay, the same idea as a delayed replica (recovery_min_apply_delay in Postgres, a delayed replica in MySQL), sized to exceed the p90 time-to-detect of your comparison loop plus time-to-freeze. Old then stays a clean image of the recent past, and the freeze turns it into a quarantine instead of a second victim.
The delay is not free, and the trade-off is where most teams stop thinking. A warm flip back now starts with old up to 30 minutes behind, so the rollback has to apply the held log first, skipping or repairing the keys on the bad-key list, which adds that apply time to the rollback p90 and therefore moves the abort deadline in 6.6 earlier. Delayed apply also only works if the held log is durable and replayable: a Kafka topic whose retention is shorter than the delay, or a CDC slot that is advanced as soon as events are read, quietly turns the buffer into data loss. The decision criterion is simple. If your time-to-detect for silent corruption is under a minute (per-request shadow diffs on the write path), keep reverse lag minimal and optimise for a fast flip back. If it is measured in reconciliation cycles, which it is for most migrations, a delayed reverse apply is the cheapest way to keep the warm tier worth having, and automated rollback should be restricted to the top row of the matrix: route-back on availability signals is safe to automate; anything touching write authority stays a human call.
Rollbacks fail in three recognisable ways, and each has a well-known public example. Rolling back code while state has moved forward. At Knight Capital in 2012, reverting the new code on the servers where it had deployed correctly left the repurposed flag pointing at old logic everywhere, which made the failure worse. The SRE track covers the incident; the migration lesson is that the rollback target must be compatible with the data and flags as they are now, not as they were before the change. Rollback that does not reach the already-affected. CrowdStrike reverted Channel File 291 about 78 minutes after release, yet machines that had already loaded it stayed in a crash loop until someone intervened by hand (see the CrowdStrike: Channel File 291 case study). In a migration the equivalent is clients, caches and downstream consumers that already absorbed new-shaped state: reverting the server does not reach them. Rollback into a system that cannot take the load. Old was downsized, its caches are cold, and its pools were drained in 6.3. Routing 100% back produces a cold-start stampede, which becomes the second incident. Keep old at full capacity through the window, and make route-back itself a ramp (fast, but not instantaneous).
GitHub’s October 2018 incident (GitHub: 43 Seconds, 24 Hours) is the reference case for the opposite decision. Writes had landed on both sides of an unplanned cross-region failover, and failing back quickly would have discarded acknowledged writes. The team chose extended degradation over data loss. A planned migration should never face that choice unprepared, but the principle carries over directly: when rollback destroys acknowledged writes, it is not a mitigation, it is a second incident with a delay.
Pitfall · the abort that nobody can call
Most cutover runbooks are written forwards: step 1 at T+0, the flip around T+90, done by T+150, leaving 90 minutes of “buffer” in a four-hour window. That buffer is an illusion, for two reasons. First, step durations are heavy-tailed, and the probability that at least one of n steps overruns its p90 is 1 − 0.9n, which is 72% for twelve steps. At least one overrun is the expected case, and the plan should be built around it. Second, the window must contain the rollback. If a rehearsed rollback takes 90 minutes at p90, the last moment you can decide to abort and still finish inside the window is 240 − 90 − margin. In the illustration that is T+135, and it arrives before the p90 plan even reaches the flip.
Build the plan backwards. Fix the window, subtract the rehearsed rollback p90 and a margin to get the abort deadline, and put a hard go/no-go gate in front of every irreversible step, with an explicit check that the deadline has not passed. If the p90 plan does not reach the flip before the deadline, the window is too short or the slice is too big. Both are fixable in planning and neither is fixable at 03:00. Per-slice cutovers, as in the Shopify: Pods, Flash Sales & the Modular Monolith and Stripe: Moving Petabytes Without Downtime case studies, shrink each window to minutes and make this arithmetic easy. A single big-bang window makes it brutal. TSB’s April 2018 migration of its customer accounts onto a new banking platform, carried out as a single-weekend cutover, is the cautionary public example: problems persisted for weeks, and UK regulators fined the bank £48.65m in 2022.
Two refinements keep the budget honest. First, a column of summed p90s overstates the p90 of the total when steps are independent, and teams use that to argue the pessimistic row away. They are rarely independent. The same slow storage volume that stretches the final sync also stretches verification, and the same missing permission that stalls one step stalls its retry, so overruns cluster. Treat the summed-p90 row as the planning case, not as padding. Second, the step with the fattest tail is almost always the final catch-up, and its duration is not the lag you see on the dashboard. Catch-up time is backlog ÷ (apply rate − ingest rate). With illustrative numbers, a replica applying 12k rows/s against 10k rows/s of live writes and ten minutes behind (6M rows) needs 6M ÷ 2k = 50 minutes to converge, and if the evening peak pushes ingest to 11.5k rows/s it needs 200. Freeze writes first and ingest drops to zero: the same backlog clears in 6M ÷ 12k ≈ 8 minutes. That is why step 2 precedes step 3, and why “lag under 2 s for 10 minutes” is the gate rather than “lag is falling”. A lag that falls slowly under live load is a lag whose final sync time you cannot bound.
#
Step
Precondition
Verify (observable)
Box
Abort to
G2
Go / no-go #2 · IC decides
CDC lag < 2 s for 10 min; reverse path round-tripped on canary shard; owners of 4 dependencies on the bridge
checklist read aloud, answers logged by scribe
5 m
stay in READS_NEW
S14
Fence group A on old · operator
phase = READS_NEW for every shard in A
write probe on old returns permission denied; fence LSN recorded
5 m
re-grant writes on old
S15
Wait for new to apply past fence
S14 verified
new.applied_lsn ≥ fence for every shard in A
10 m
re-grant on old (nothing lost: fenced)
S16
Start reverse CDC new → old
S15 verified
reverse lag < 5 s; synthetic row written on new appears on old
10 m
stop reverse; re-grant old
S17
Open writes on new · phase → WRITES_NEW
S16 verified; abort deadline not passed
write probe OK; old-side writes per caller = 0; SLO burn normal
5 m
rollback R3 (fenced flip back)
The anatomy in the excerpt is the point. Every step names a precondition (the previous step’s verification, never merely its completion), an observable proof that someone other than the operator can check, a timebox whose breach is itself an abort trigger, and its own way back. A step with no way back is a door and belongs in the door list from 6.4. Mechanical steps belong in code: the fence, the LSN wait and the reverse-CDC start are one script with idempotent re-entry, so a crashed laptop mid-step is a rerun, not an improvisation. Gates stay human, and are read aloud and logged. Roles separate cleanly: an incident commander who owns go/no-go and nothing else, an operator who executes, a verifier who checks proofs independently, a scribe, and a comms lead. The operator should never be the one deciding whether to continue, because the operator is the person most invested in continuing.
On an online slice flip, fence-to-open is a write outage; budget it in seconds. The excerpt above timeboxes S14–S17 in minutes because it runs inside a maintenance window. A per-slice online cutover has no window, so the interval between the fence on old and write authority reaching callers of new is user-visible unavailability for that slice, and it decomposes into parts that are individually easy to underestimate. The fence itself is fast, but a revoked grant blocks the next statement, not the COMMIT of a transaction whose writes already executed, so the fence LSN is only meaningful once no write transaction that started before the revoke is still open. Without a bound (a statement timeout, an idle-in-transaction timeout, or terminating those backends outright) that wait is set by your slowest caller, which is usually a batch job holding a transaction open across a network call. Catch-up to the fence LSN is short only because the gate held lag under 2 s. And “open” is not the phase write; it is the moment the last router learns about it, so a 15-second flag poll puts 15 seconds into every slice’s outage.
Two thresholds matter. Below a few seconds, client retries with backoff absorb the gap and nobody outside the bridge notices. Past the request timeout, callers see errors, and the queued and retried writes arrive at open as a burst: with the illustrative figures in the diagram, a 48-second gap at 2,000 writes/s is ~96k writes, amplified up to fourfold by retries, landing on a store whose pools and caches are cold (6.3). The engineering that collapses the gap is unglamorous: push the phase change to routers rather than waiting for polls, kill pre-fence write transactions instead of waiting for them, make fence → LSN wait → reverse-CDC arm → open one idempotent script with no human in the middle, and keep the human gate before the fence, where waiting costs nothing. If the engineered gap still exceeds your clients’ retry budget, the slice is too hot to flip online; split it, or give it a maintenance window and plan it with the window budget above.
Rehearse twice, for different reasons. The first rehearsal, on a production-sized copy with the real people, finds missing steps: the grant that also needed a sequence permission, the dashboard that times out on a full table. The second measures durations, and those measured p50/p90 values replace the guesses in the budget above. Rehearse the rollback with a stopwatch too, and at least once past the flip on a low-risk production slice, as chapter 01 argued. A rollback duration that has only been estimated makes the abort deadline an estimate as well.
Design review · questions to ask before the date
“Can we roll back?” has three different answers depending on the date, and plans that treat rollback as a single capability tend to lose all three at once. Hot rollback is route-back while new is serving reads only: minutes, lossless, and free until the write flip. Warm rollback is the fenced flip back over verified reverse replication: tens of minutes, lossless only while no new-only states exist, and it needs old kept warm. Cold rollback is restoring a final snapshot of old and replaying new’s change log translated back into old’s model: hours to days, lossy for anything old cannot represent, and it needs both the snapshot and a translator that still compiles. Each tier needs different things kept alive, so they should expire on purpose and in order, not all at once when a cost-cutting ticket decommissions the old cluster.
Hot · route back
time to restore
minutes
data loss
none
must stay alive
old fleet at full capacity, reads still valid, phase ≤ READS_NEW
available
reads-only phases; free until the write flip
Warm · fenced flip back
time to restore
tens of minutes
data loss
none, if reverse sync is verified
must stay alive
reverse CDC running and diffed, no new-only states, old warm
available
write flip → end of window
Cold · restore + replay
time to restore
hours to days
data loss
lossy for new-only data; manual reconcile
must stay alive
final snapshot of old + a translatable change log from new
available
end of window → snapshot expiry
Closing the warm tier is the real point of no return for most migrations, and it deserves exit criteria as explicit as the ones for leaving shadow mode in chapter 03. The window has covered the longest business cycle that matters: a month-end, and a quarter-end if finance reads the data. At-rest reconciliation between new and the reverse-synced old has run clean for that whole period. Old-side traffic per caller has been zero for at least one full cycle, including the batch jobs that run monthly. Every door in the list is closed deliberately, with its owner’s sign-off. And the cold tier is verified as restorable, by restoring it, before reverse sync is turned off. That last check is cheap and almost never done. A snapshot nobody has restored is the same kind of hypothesis as a rollback nobody has rehearsed.
The warm tier also decays on its own, and usually closes quietly well before anyone decides to close it. Three mechanisms do most of the damage. Schema drift on new. Every column, enum value or constraint added to new during the window must be representable in old and handled by the reverse translator, or reverse sync starts dropping or rejecting rows. The honest options are a schema freeze on new for the window, or making “reverse translator updated and diffed” a required check on every new migration. Without one of them, the first feature team to ship a new status value closes the warm door without knowing it existed. Silent reverse-sync divergence. A reverse pipeline that nobody reads from fails without anyone noticing: a poisoned message skipped by a dead-letter policy, a type coercion that truncates. Warm rollback depends on the continuous at-rest reconciliation above, not on the pipeline’s own lag metric, which stays green while it drops rows. Operational rot on old. Certificates expire, base images miss patches, credentials rotate on new’s schedule but not old’s, and the engineers who knew old’s failure modes move on. Put old’s certificate and secret expiry dates on the window calendar, and run a scheduled warm-rollback drill on one low-value slice partway through the window. If the drill fails, the warm tier has already closed, and you would rather learn that on a Tuesday than during an incident.
Then close the doors in order: enable new-only features, retire the compatibility projector, stop reverse sync, downsize old, and finally delete the snapshot on a date that was announced in advance. Each is a separate change on a separate day, so that if something breaks you know which door caused it. The cost of keeping the warm tier alive (the reverse pipeline, a full-capacity old fleet, and the compat projector) is real, and it is exactly the carrying cost chapter 01 warned about. Budget it for the window you chose, and close the window when its criteria are met, not when the budget runs out.
minutes
hot · route back
tens of min
warm · fenced flip back
hours–days
cold · restore + replay
1 cycle
clean before warm tier closes
Where next