Lesson 12 of 13 · 14m
Half Your Fleet Is Always Behind
A rolling deploy is a window where N and N−1 coexist, so every contract — schema, wire format, API — must be compatible in both directions.
A rolling deploy is not a state transition. It is a window — minutes on a small fleet, hours on a large one — during which version N and version N−1 serve traffic simultaneously. On a fleet that deploys daily, the "everyone runs the new code" state is the brief exception, not the rule. The implication that bites: every contract two versions share — the schema, the message format, the API — has to work in both directions for the whole window.
The expand-migrate-contract answer
Schema changes get a standard recipe precisely because the naive one breaks the window. Renaming users.email to users.primary_email in one release means old code reads a column that no longer exists and new code reads one that does not yet — somebody errors for the entire rollout. The recipe instead:
- Expand: add
primary_emailas a new nullable column. Deploy code that dual-writes both columns. - Migrate: backfill old rows.
- Contract: switch readers to
primary_email, deploy, and dropemailin a later release — never in the deploy that stops writing it.
Every step is independently safe under a mixed fleet, which is the entire point. Postgres adds a landmine worth knowing by name: ALTER TABLE takes an ACCESS EXCLUSIVE lock, so a migration that queues behind a long transaction blocks the table — set lock_timeout and retry rather than serialize your deploy behind someone else's analytics query. For zero-downtime reshaping, pg_repack rebuilds tables online; on MySQL, gh-ost (GitHub's own tool, built for exactly this) and pt-online-schema-change do the shadow-table dance.
Wire formats obey the same logic. Protobuf's rule is mechanical: never reuse field numbers; mark deleted fields reserved so the next contributor cannot reintroduce the number with a new meaning. Old consumers must ignore unknown fields — that is what the binary format is for — and new code must tolerate records written before it existed. Forward and backward compatibility, at once, for as long as the rolling window lasts. JSON is friendlier about it — unknown keys are free to ignore — and more dangerous: JSON types invite coercions (a field that flips from string to int mid-fleet) that protobuf's numbered, typed fields make unrepresentable.
The ordering rule that follows: tolerant consumers deploy before producers. The version that understands both shapes goes out first; only then does anyone emit the new shape. Reverse the order and you guarantee a window where writers produce bytes no reader can parse — the failure is not probabilistic, it is scheduled.
Deploy and activate are different verbs
Feature flags decouple "the code is everywhere" from "the code is live." Rollout order stops mattering; rollback stops being a redeploy — it is a flag flip, which is the difference between a 30-second mitigation and a 20-minute one while the error budget burns. Flags do not remove the compatibility requirement: the flag-off path still has to coexist with the flag-on data the other half of the fleet is writing.
And "we can just roll back" deserves the same scrutiny as the lock without a fence. Rolling back to a version that cannot read the data the new version already wrote is not a rollback — it is a second outage with extra steps. The two-deploy rule covers it: a contract change takes at least two deploys, one where both sides understand both shapes, and only then a deploy that drops the old shape.
What to actually do
Additive changes first; removals always one deploy behind; lock_timeout on every DDL statement; consumers that read both shapes before producers stop writing the old one; flags on risky paths; and a CI job that runs the previous release's test suite against the new build — because the compatibility that matters is the one between versions, and that is precisely the test nobody writes unless someone makes them.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
What is Platform as a Service? The Sweet Spot Between "Too Easy" and "Too Much Work"
Platform as a Service sits between raw servers and fully managed software. You push code, the platform runs it. No Nginx config, no OS patches, no 3 AM server alerts. Here is what PaaS actually gives you, what it costs you in control, and how to decide if it is the right layer for your application.
The World now is Serverless and Container based
A new report from Datadog reveals that serverless computing could be entering the mainstream. This has already been the case in my world for the past few years. Results show that more than half of all organizations are using serverless on one of the three major public cloud providers: Amazon,
AWS Emulator Puts AWS on Your Laptop. Keep Your IAM Tests Off It.
AWS released AWS Emulator on November 11, a free local server that answers AWS API calls on 127.0.0.1 with per-run keys and fresh certificates.
A 257-Byte Password Is the Key: Inside the OpenSSH musl Bypass
CVE-2026-123158 lets an attacker log into a locked account on musl-based systems like Alpine by sending a password nobody set. The trigger is one number, 257, and the reason is a C library returning a single asterisk. I reproduced the exact boundary against musl 1.2.4 and read the fix.