Shelves / Production Deployment
DP·CS
Case Study — Launch Week Game Day
The whole volume applied in one exercise: TiffinBox prepares to launch bulk skip for office admins in Hyderabad's HITEC City and runs a game day the week before. Readiness review findings, the environment and deploy plan, the migration plan with lock analysis, four injected failures (a lock-queue stall from a migration, a bad canary, a payment-provider outage, and an accidental data deletion needing point-in-time recovery), the team's responses against a timeline, the scoring rubric, and the postmortem with its action items. Attempt each decision before reading the answer.
Start here: why rehearse a launch
A game day is a planned exercise where a team deliberately injects realistic failures into a production-like environment and practises responding. Fire drills feel unnecessary until the fire; game days find the gaps in runbooks, alerts, permissions and habits while the cost is a morning, not a customer outage. This case study runs one for TiffinBox's "skip v2" launch week: a readiness review, a migration plan, four injected failures (a migration that stalls everything, a bad canary, a payment-provider outage and an accidental deletion), scoring, and the launch decision.
How to work through it. At each "Decision" stop and write your answer before opening the model answer; then compare. Each injection draws on one chapter: A on chapter 191, B on 192, C on 188–189, D on 193. Experienced readers can jump to the injections and the scoring rubric.
How deep to go in game days
Volume 17 defines six mastery levels; for game days and launch readiness they look like this:
| Level | You can… |
|---|---|
| L1 | explain what a game day is and why teams run them |
| L2 | take part in one and follow the runbooks |
| L3 | design injections that test specific controls and score the response |
| L4 | lead the response to an injected (or real) failure and run the postmortem |
| L5 | plan a launch-week programme of readiness reviews and game days |
| L6 | make game days and chaos experiments a routine organisational practice |
The setting
TiffinBox is launching bulk skip (an office admin skips lunch for many employees at once, e.g. for an offsite) for its first 40 corporate offices, on Monday. On the Wednesday before, the team runs a game day in staging, which since chapter 190 mirrors production's infrastructure, deploy pipeline and data volume (synthetic, 60,000 subscribers). The incident commander for the day is the on-call engineer of the week; a facilitator (the platform lead) injects failures without warning, and two observers keep the timeline.
Release contents: API v1.9 (bulk endpoint behind flag bulk-skip), a migration adding skip_batch and a batch_id column on credit_entry, an index on delivery (subscription_id, delivery_date) for the bulk lookups, and a worker change to process BulkSkipRequested events.
Part 1: readiness review findings
The readiness manifest (chapter 189) for bulk-skip scored:
functional 4/4
performance 3/4 load_test_peak_2x: done (10 concurrent admins × 300 employees at 06:55)
security 5/5
reliability 3/4 backup_restore_tested: last restore drill 41 days ago → BLOCKER
observability 3/4 dashboards: no panel for bulk_skip_items_total{result} → follow-up
operations 4/4
Decision 1: the last restore drill was 41 days ago. Block, or proceed?
Part 2: the migration plan
The proposed migration, as first written:
-- V23__bulk_skip.sql (first draft)
CREATE TABLE skip_batch (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
office_id bigint NOT NULL,
requested_by bigint NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE credit_entry ADD COLUMN batch_id bigint REFERENCES skip_batch(id);
CREATE INDEX delivery_sub_date ON delivery (subscription_id, delivery_date);
Decision 2: what's wrong, and what's the safe version?
Part 3: the injected failures
Injection A, 10:05: the migration stalls everything
The facilitator starts a long analytics query in a transaction on staging's credit_entry (simulating the finance team's monthly report on the primary), then the team runs the migration job as part of the deploy, using the first draft by mistake (the facilitator swapped the file). Within 30 seconds the skip success rate drops to zero and the API's p95 hits 10 s.
Decision 3: first three actions?
Injection B, 11:20: a bad canary
The corrected release goes out. The facilitator has planted a bug: for offices with more than 255 employees, the bulk endpoint returns 500 (a byte used for a count in a batching helper). Only 3 of the 40 launch offices are that large. Canary at 5%, then 25%.
Decision 4: does the canary analysis (error ratio < 0.2% over 5-minute windows) catch it? What should?
Injection C, 12:10: payment provider outage
The facilitator blocks egress to the payment provider's sandbox with a network policy during the lunch-hour renewal batch.
Decision 5: what should users and the system experience?
Injection D, 14:30: accidental deletion
The facilitator, playing a support engineer with an over-privileged role, runs a "cleanup" that deletes all credit_entry rows with reason = 'adjust' for the last 30 days, 1,840 rows representing goodwill credits. The ledger invariant check (chapter 191) notices that 212 subscriptions now have negative balances (they had already redeemed the goodwill credits) and alerts at 14:41.
Decision 6: recovery plan, and the deeper fix?
Part 4: scoring
The facilitator scores the day with a rubric, so improvement between game days is measurable:
| Dimension | 1 (poor) | 3 (adequate) | 5 (excellent) | Score |
|---|---|---|---|---|
| Detection | Users/facilitator told us | Alert within 15 min | Alert within 5 min, symptom-based | 3 |
| Diagnosis | Guessing, restarts | Systematic, slow | Dashboards/runbook led straight to cause | 3 |
| Mitigation | Fix-forward under pressure | Rollback/flag used | Automatic (timeouts, canary abort) or one documented action | 3 |
| Communication | None | Channel updates | IC cadence, status page, support briefed | 4 |
| Data recovery | Not possible | Possible with improvisation | Rehearsed procedure, validated | 3 |
| Runbooks | Missing | Exist but outdated | Accurate, followed, improved same day | 2 |
Overall 18/30. Not a failure: the point of a game day is to find these before Monday.
Part 5: postmortem and launch decision
Summary: four injected failures; all mitigated in staging; mean time to mitigate 17 minutes; two issues (migration linting gap, canary blindness to low-volume routes) would have caused customer impact on launch day; one (over-privileged support role) is a latent production risk today.
Action items (owner, due):
- Squawk in CI with
require-timeout-settingsandrequire-concurrent-index-creation; migrations shipped inside the versioned image (platform, Fri). - Per-route canary analysis for flagged features, plus
bulk_skip_items_totalpanel and alert (api team, Fri). - Property-based test for office sizes 0..2,000 on the bulk path (api team, Fri).
- Jittered, rate-limited backlog replay for payment retries (payments, next sprint; launch not blocked because grace period covers it).
- Remove support's direct DB write access; ledger
DELETErevoked and trigger-guarded; invariant check every 5 min (platform + support lead, Fri). - Restore-drill failure pages on-call; fix alert routes; monthly alert-route test (platform, done Wed).
- Runbook updates: lock-chain diagnosis in "SkipErrorBudgetFastBurn"; PITR copy-back steps with exact queries (on-call, Thu).
Launch decision (Thursday review): items 1, 2, 3, 5 and 6 done → launch Monday, flag enabled for the 37 offices under 255 employees first, the 3 large offices on Wednesday after the fix has run in production for two days. Deploy at 10:00 Monday (after the morning rush, steady traffic for the canary), with the release runbook (chapter 192).
Lab: making injections A and D impossible
Setup. PostgreSQL 16 and Python on the lab machine. The game day's postmortem proposed two "make it impossible" fixes; the lab implements both and tests them against the injected mistakes. (The underlying behaviours, the lock queue and point-in-time recovery, were measured in chapters 191 and 193's labs.)
Experiment 1: an append-only ledger rejects the "cleanup"
A credit_entry table with 20,000 rows and a statement-level trigger that rejects DELETE and UPDATE:
create function no_delete() returns trigger language plpgsql as $$
begin raise exception 'credit_entry is append-only: write a compensating entry instead'; end $$;
create trigger credit_entry_no_delete before delete or update on credit_entry
for each statement execute function no_delete();
delete from credit_entry where reason = 'adjust';
ERROR: credit_entry is append-only: write a compensating entry instead
insert into credit_entry(sub_id, amount, reason) values (7, -120, 'reversal of #70');
→ 20,001 rows, balance updated, history intact
Injection D's deletion now fails instantly instead of needing a 58-minute recovery, and corrections become visible, auditable compensating entries. Combine it with privileges (REVOKE DELETE, UPDATE ON credit_entry FROM app, support) so the trigger is a second line of defence, not the only one; note that the table owner and superusers can still disable triggers, which is why support roles must never own tables.
Experiment 2: a migration linter in CI
A 15-line linter with three regular-expression rules, run over four migrations:
| Migration | Result |
|---|---|
0007_add_note.sql: ALTER TABLE … ADD COLUMN note text; |
FAIL require-lock-timeout |
0008_index.sql: SET lock_timeout; CREATE INDEX … |
FAIL index-not-concurrent |
0009_safe.sql: SET lock_timeout, SET statement_timeout, CREATE INDEX CONCURRENTLY … |
ok |
0010_default.sql: SET lock_timeout; ADD COLUMN token uuid DEFAULT gen_random_uuid() |
FAIL volatile-default-rewrite |
Exit code 1 blocks the merge. Injection A's draft migration (no lock_timeout) would have been stopped here, and the second half of that fix, shipping migrations inside the versioned, digest-verified image, ensures the file that ran is the file that was linted. A mature setup uses Squawk or a similar tool with many more rules; the point is that each postmortem action item becomes an automated check where possible.
Revision sheet: launch-week game day
Key ideas
- Game days rehearse failure on purpose: readiness review → plan → injected failures → scoring → postmortem → launch decision.
- Mitigate first (stop or roll back the change), then diagnose; look at locks, not just app dashboards, when a migration coincides with an outage.
- Canary analysis must compare against a baseline and stop automatically on clear harm.
- Third-party outages need timeouts, queues, degraded modes and honest messaging.
- Accidental deletions are recovered with PITR into a separate instance and selective copy-back; the deeper fix makes them impossible (least privilege, append-only ledgers).
- Score detection, mitigation and recovery times and the quality of decisions; turn every action item into an automated check where possible.
Numbers to remember
- Case: injection A mitigated in 10 minutes (0 with
lock_timeout); injection D detected in 11 minutes, recovered in 58. - Lab: an append-only trigger made the deletion fail instantly; the linter flagged 3 of 4 migrations.
Pitfalls
- Investigating dashboards while the bad change keeps running.
- Migrations fetched from mutable paths instead of the versioned artefact.
- Support roles with direct write access to financial tables.
- Action items that stay as wiki text instead of becoming checks.