Unit 9 of 15 · about 4 hours · explain, implement

Rolling protocol and schema evolution, mixed-version behavior and feature gates

Deploys are mixed-version states, not instants. Every pair of old and new code that can meet must already agree on the wire format, and every subject must land on the same side twice in a row.

You'll be able to

  • State backward and forward compatibility for each mixed reader and writer pair in a rolling upgrade.
  • Roll flags and versions out to a stable slice of subjects with deterministic sticky assignment.
  • Gate a cutover on ordered readiness checks with drain accounting and a valid rollback.

Covers

Rolling protocol and schema evolutionMixed-version behavior and feature gates
1

Read

In this order, only the parts listed

0 of 2 done

  1. DDIA 2e Chapter 5: compatibility directionsDDIA 2e - Chapters 2, 5 and 14

    Chapter 5, Encoding and Evolution: backward and forward compatibility definitions (p. 162); Avro reader-writer compatibility (pp. 174-175); Dataflow Through Databases (pp. 178 to 179); Data encoding and evolution for RPC (p. 186)

  2. Deployments: rolling, blue-green, canary, flagsHLD Handbook - Reliability, Operations and Security at Scale

    Deploy vs release; Rolling deploys; Blue-green; Canary with automated analysis; Feature flags as the release control plane

    Read for the strategy mechanics. Leave Database migrations and expand-contract to the next unit.

2

Focus on

  • Name the writer and reader versions in each direction. New-writer with old-reader needs forward compatibility; old-writer with new-reader needs backward compatibility.
  • Deploy is not release. A flag separates shipping code from exposing behavior, so a bad release rolls back by flipping the flag, not by redeploying.
  • Compute the deterministic bucket from the same subject ID on every request. Fresh random assignment, or changing the hash algorithm, salt or subject identity, can flip users mid-rollout.
  • A rolled-back cutover is valid but incomplete: green stays deployed and switchable, and blue retires only after every old connection drains.
Common mistakes · 3
  • Testing only new-to-new pairs. Mixed pairs are the rollout: the old reader that chokes on the new field is the outage.
  • Relying on an unspecified built-in hash. For the exercise's printable-ASCII IDs, start with h = 0 and update h = (h * 31 + ord(c)) & 0xFFFFFFFF for each character c; the bucket is h % 100.
  • Retiring blue before drains finish. The cutover auditor keeps blue until green is active and every pre-existing connection has closed.
3

Try it yourself

Closed-book, before checking anything

Without notes, state the compatibility direction each mixed pair needs when a rolling upgrade adds an optional field, and compute bucket and enablement for two user IDs under the sticky hash at 50%.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.A rolling upgrade adds an optional field. Which direction does a new-writer with old-reader pair need?Answer

    Forward compatibility: the old reader must handle data from the newer writer, for example by ignoring the unknown field.

  2. 2.Which direction does an old-writer with new-reader pair need?Answer

    Backward compatibility: the new reader handles older data, supplying a default for the missing field when the encoding requires one.

  3. 3.Users land in buckets 40, 17, 9 and 76 at a 50% rollout. Who gets the feature?Answer

    Buckets 40, 17 and 9. Enablement is bucket < 50; bucket 76 waits.

  4. 4.A cutover switches to green, then rolls back to blue. Is the trace valid?Answer

    Valid but incomplete. Rollback to retained blue is legal; completion additionally needs green active with blue retired and drained.

5

Practice

You're done when

Your mixed-pair table names both directions correctly, bucket math matches the pinned hash, and a cutover trace with gates, drains and a rollback audits clean.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 15 more in the section
  • HLD Handbook - Reliability, Operations and Security at ScaleHLD Handbook · primary

    Read Part 6 observability, SLOs, resilience, overload, deployments, chaos, incidents and health, then Part 7 authentication, mTLS, secrets, tenancy and data governance chapters relevant to the capstone. Skip unrelated case studies.

  • DDIA 2e - Chapters 2, 5 and 14Martin Kleppmann and Chris Riccomini · support

    Use Chapter 2 "Describing Performance" for percentile and response-time vocabulary and Chapter 5 for compatibility during rolling upgrades. Chapter 14 is about predictive analytics, privacy and data governance, not operations: read its "Privacy and Tracking" section for the retention and deletion units.

Also in this section

  • Google SRE Books - SLOs, Monitoring, Overload, Cascades, Incidents and RecoveryGoogle · required

    Read SRE Chapter 4 (service level objectives), 6 (monitoring distributed systems), 21 (handling overload), 22 (addressing cascading failures), 14 (managing incidents) and 15 (postmortem culture); Workbook Chapter 2 (implementing SLOs) and 5 (alerting on SLOs); and Building Secure and Reliable Systems Chapter 5 (least privilege) and 9 (design for recovery). Convert each into one alert, limit, load test or runbook action in the capstone.

  • Metastable Failures in Distributed Systems (Bronson et al., 2021)HotOS · support

    Read the trigger and sustaining-effect model of metastable failure and the retry and shedding design prompts. Its model illustrates; it does not predict.

  • Metastable Failures in the Wild (Huang et al., 2022)USENIX OSDI · support

    Read the incident study for how retries and load sustain outages after the trigger ends; it is a sample of public reports, not a rate.

  • Simple Testing Can Prevent Most Critical Failures (Yuan et al., 2014)USENIX OSDI · support

    Read the findings on error-handling code and how few nodes and events reproduce most failures, as the case for testing error paths in your campaign. Its bounds come from one sample of 2014 systems.

  • Gray Failure: The Achilles' Heel of Cloud-Scale Systems (Huang et al., 2017)Microsoft Research · support

    Read the gray-failure model (differential observability between a detector and its clients) as vocabulary for telemetry and failure detection.

  • The Internals of PostgreSQL - Base Backup and Point-in-Time RecoveryHironobu Suzuki · support

    Read Chapter 10 (base backup, how PITR replays WAL, timelines and incremental backup) as the real-engine model for backup integrity, recovery points and restore verification. Note the date you read it.

  • Building Distributed Systems - The Tracer, The Securitor and The MigratorBuild Distributed Systems · optional

    Only the first three tasks of each track are free: in The Tracer, trace-context propagation, span lifecycle and a collector; in The Securitor, JWTs, the OAuth 2 code flow with PKCE and sessions; in The Migrator, schema migrations, expand and contract, and zero-downtime change. Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.

  • SPIFFE Workload Identity and Workload APISPIFFE Project · support

    Read the SPIFFE ID, X.509-SVID and trust bundle specifications and the Workload API (FetchX509SVID, FetchX509Bundles) to design service identity, short-lived credentials and bundle rotation. A local mock is sufficient unless a real SPIRE deployment answers a specific gap.

  • OpenTelemetry Signals and Semantic ConventionsOpenTelemetry · support

    Read signals and context propagation (W3C Trace Context traceparent, inject and extract, baggage rules), then the semantic conventions (1.44.0) for the RPC and messaging areas with their stability status. Define bounded attributes for request, node, partition, term and offset identities, and never infer global order from display timestamps.

  • Replicated Log and Stream Processor - Production ContractRoadmap-Final · support

    Add workload identity, tenant checks, audit, SLOs, capacity limits, backup and verified restore, mixed-version migration, rollback and reduced point-in-time ML data paths. Run one compound incident from detection through recovery.

  • OWASP Threat Modeling Cheat SheetOWASP · reference

    Use System Modeling (data-flow diagrams, trust boundaries, stores and processes), Threat Identification (the STRIDE table applied to components, data flows and trust boundaries) and Response and Mitigations to build the unit threat model.

  • Feast Documentation - Point-in-Time Joins and Feature RetrievalFeast · support

    Read Point-in-time joins (entity dataframes, get_historical_features, TTL backward scan, filter_by_created_timestamp) and Feature retrieval (event_timestamp as the inclusive upper bound, get_online_features without timestamps, feature services per model version, materialize refresh). Work the join logic on tiny local tables; do not deploy Feast. Page read 2026-10-15 (v0.66-branch documentation).

  • MLflow Model Registry DocsMLflow · support

    Read the Model Registry page (registered models, versions, lineage to the producing run, aliases such as @champion, and tags) and the registry tutorial promotion flow. Stages are deprecated since MLflow 2.9; use aliases and tags. Page read 2026-10-15; the versioned docs move, so re-pin the version you read.

  • DVC Docs - Data VersioningDVC · support

    Read dvc add (Description and Example: Single file) for .dvc content-hash sidecars, the dvc.yaml page with its dvc.lock file section for pipeline state, and push and pull for transfer. A local directory remote is enough; do not set up cloud storage. Page read 2026-10-15.

  • PostgreSQL 18 Documentation - Recovery Targets, Backup Verification and RewindPostgreSQL Global Development Group · reference

    Read Section 19.5.6 Recovery Target, the pg_verifybackup reference and the pg_rewind reference for recovery stopping points, manifest checks and rejoining a diverged primary.