Skip to content
Muhammet Şafak
tr
8 min read

Upgrade Rollout and the One-Way Doors

A traffic share can be pulled back; a written row cannot. The one-way doors in a rollout, and the proof to ask for before crossing each.

TL;DR

A gradual rollout does not make an upgrade reversible. Image tags, traffic share and config roll back; schema and data, serialized state and external contracts do not. Split every one-way door into expand, migrate and contract, and write down the proof you need before crossing each step.

Small gray hatch in a wall, slightly ajar, with a brass latch

You can pull back a traffic share; you cannot pull back a written row.

That is why a gradual rollout does not make an upgrade reversible. Martin Fowler’s canary release opens the new version to a small set of users first, which means two versions are live at the same time. If both write to the same database, the data has to work with both. When the share is pulled back, the rows the new version wrote stay where they are.

Part 5 had you write the evidence for four gates and sent nothing to production. Now we send. Keep two separate questions in mind: in what order do we go out, and which step can we not undo once we have?

A Rollout Is a Sequence

Write the sequence as four stops: staging, a small share, a growing share, everything. Next to each stop, write two things.

The first is the rollback cost: how much work, how much time and who is involved in returning to the state before this stop? The second is the stop criterion: which observation pauses the rollout or starts the rollback? Write the criterion before the rollout, not during it. A “let’s watch a bit longer” decided under pressure is not a criterion.

The number in the criterion is per system. This article cannot tell you which error rate or which latency is enough to stop, and the same goes for the traffic share percentages. What I can say is that the number has to be written before the rollout starts, and its owner is known: the name of the person who makes the stop decision sits next to the number.

Amazon’s 2016 shareholder letter splits decisions in two: many are reversible, “two-way doors”. In this article “one-way door” is my own term: a step after which going back is blocked not by the code you write but by freshly written data or a promise made to the outside. For reversible doors, moving fast is enough. For the others you have to slow down, and the shape of slowing down is below.

As you write the rollback cost for each stop, one will come out non-zero, perhaps infinite.

Which Step Cannot Be Undone

The reversible ones are easy: image tag, traffic share, config. Gate 4 in Part 5 showed it: the previous image can be pulled and the previous lock is at hand. The irreversible ones sit where data and promises are:

DoorReversible?Proof before crossing
Image tag, traffic share, configYes: the previous tag and values are at handThe rollback record from Part 5
Schema and data migrationThe structure partly; the data noA staging record where down was run and the data checked afterwards
Serialized state: queue payload, cache, sessionIf the new version wrote it, the old version may not be able to read itA staging run showing the old version reading a record the new version wrote
External contract: API response, webhook, event payload, signed tokenNo, if a consumer acted on itA contract test or consumer sign-off showing the old and new shapes are both valid

Let us open the rows in order.

Schema and data migration. The Laravel documentation asks the down method of a migration to reverse the operations of up; it also says some migration operations are destructive, may cause you to lose data, and ask for confirmation before running in production. The conclusion that follows is my reasoning, not the documentation’s: down rebuilds the structure, not the data. Adding a column back does not bring the deleted values back. If the new version wrote to that column and down drops it, what was written is gone.

Serialized state. A record written to a queue, a cache or a session outlives your code. PHP’s unserialize documentation says an object whose class has no definition comes back as __PHP_Incomplete_Class. If the new version renamed or removed a class and you go back to the old version, the same can happen in the other direction. Laravel workers are long-lived processes; they do not see a code change until they are restarted, and queue:restart exists for that. If two versions process the same queue for a while, which one wrote the payload decides the outcome.

External contract. A field in an API response, a webhook body, the schema of an event payload, the contents of a signed token: these live outside your code. If a consumer has acted on the new shape, rolling back the image does not roll back what the consumer did. I cite no primary source for this row; it is reasoning. You know which consumers your system has.

The three rows share something: the rollback is tested not in your code but in something that has become permanent or sits in someone else’s hands. So the proof column shows that thing, not the code: a rollback run on staging, an old record that was read, a contract test that passed. “The code looks right” does not count as proof.

Split the Door

Do not cross a one-way door in a single step. Fowler’s ParallelChange pattern has three phases: expand, migrate, contract.

  • Expand: add the new shape, do not delete the old one. A column is added, the old column stays. Both versions work.
  • Migrate: move consumers and data to the new shape. While both shapes are valid, every step is reversible.
  • Contract: remove the old shape.

For a rollout the consequence is this: three phases become three separate deploys. Expand is safe for both the new and the old version; if you roll the image back, the old version still works. Contract is the real one-way door and happens after the rollback window has closed. The window is your definition: the moment the new version carries all the traffic and you decide you will not return to the old one.

Let us state the cost plainly. You need at least one extra deploy, and in the in-between period the code carries two shapes at once: it writes to both the old and new column, reads both the old and new payload. That code is temporary, but temporary code that is forgotten becomes permanent. The expiry condition: when the contract step is done, the in-between code is deleted. Write the name and the date of whoever will do the contract next to the in-between code.

The same pattern works for serialized state: first let the new version read both shapes, then change which version writes, and only last stop reading the old shape.

Rector Dry-Run

A code change can be a door too. If upgrading the runtime (in the example, from 8.2 to 8.4) and adapting the code to the target happen in the same deploy, you cannot tell which one is responsible when something breaks.

Rector transforms code automatically. vendor/bin/rector src --dry-run does not apply the change; it shows it as a diff. An example: PHP 8.4 deprecates a typed parameter with a null default (string $name = null) and asks for ?string $name = null. I am not claiming here which Rector rule makes this transformation; if you see this line in the diff, you read what changed.

What matters about this transformation is that it is also valid on the old runtime. So ship it as its own deploy, before the runtime change. That leaves the runtime change alone, and a reversible step.

The question the dry-run does not answer: is the transformation actually valid on the old runtime? The diff does not say. The suite running on your current image does; Part 5’s baseline exists for exactly this. The dry-run is for seeing the diff; the suite is the proof of safety.

The Plan Page

Write the rollout plan on one page:

StepRollback costStop criterionProof before crossing
Rector transformation (valid on the old runtime)Go back to the old imageSuite red, error rate over the thresholdGreen suite on the current image
Runtime change, stagingPrevious tagSuite red on stagingSuite output on the target image
Small shareReset the shareThe threshold written in advanceThe staging record
ExpandPrevious image; the new column staysThe old version errors on the new shapeA run where the old version reads the new shape
MigrateWrite the data back to the old shapeAn inconsistency is foundA check showing both shapes are equal
ContractNoneOnly once the rollback window has closedA record that the window closed, and an owner for deleting the in-between code

Fill in the numeric thresholds yourself. The word “None” in the contract row is not a mistake, it is a marker: that row is your one-way door.

Where This Framework Stops

The table shows the order and the doors; it does not give you thresholds, traffic share percentages or the length of the in-between period. Those are your system’s answers: which error rate stops the rollout, in how many steps the share grows, when the rollback window closes.

Tool choice (feature flag product, deployment tool, traffic routing) is out of scope; the logic of the doors is independent of the tool. The external contract row is reasoning, not a sourced fact; review your own consumers. The Fowler pages are not pinned to a version number; read the Laravel and PHP documentation for the version you run.

Who decides, who is on call and who signs off is the subject of Part 7. The cases where not upgrading at all is legitimate belong to Part 8.

The Door You Cannot Pull the Row Back Through

Back to the opening line: which step in your plan is the door where you cannot pull back the written row?

Write your rollout plan. Add the rollback cost and the stop criterion to every step; for every one-way door, write the proof you will show before crossing.

Sources

Related

Comments

Sign in with your GitHub account to join the discussion. Comments are stored in GitHub Discussions.

Search the site

Start typing to search posts, projects and pages.

Esc to close Powered by Pagefind