Safe Releases, Rollbacks and Database Changes

Deployment success versus release success, rolling, blue-green, canary and feature flags, expand-and-contract migrations, and why rollback is not always a database rollback.

  • Advanced
  • About 18 minutes
  • Includes an exercise and a knowledge check

The concept Deployed is not released

Version 1.5 deploys, the container is healthy, and finance reports that search no longer returns the expected results. The deployment succeeded; the release failed. A safe release verifies behavior and business workflows after deployment.

On the left, a historical photo of a miner holding a canary in a cage. On the right, a canary release: 5 percent of traffic on 1.5, then 25 percent, then 100 percent when checks pass. At every step check error rate, p95 latency, payment ingestion, settlement processing and reconciliation results; if any check fails, traffic goes back to 1.4. Below, expand and contract in five steps: expand (add a new column), deploy (code reads both), migrate (backfill), verify, contract (remove the old column in a later release).
Send the canary in first, and change the schema in steps.
StrategyHowGood for
RollingReplace instances graduallySimple, compatible changes
Blue-greenRun two environments, switch traffic after validationFast switch back, if the database is compatible
CanarySmall share of traffic first, then widenCatching problems with limited impact
Feature flagsTurn functionality on without redeployingNew rules, such as a reconciliation rule, for a subset first

Data changes Rollback is not always a database rollback

If 1.5 renames a column while 1.4 tasks still run, 1.4 breaks mid-deployment. Expand and contract avoids this. And reverting a migration after production data changed can destroy information. For Apex: prefer backward-compatible migrations, preserve audit records, understand partial processing, use compensating actions where needed and reconcile business data after recovery. Never assume reversing a script reverses a financial operation.

Background work Workers need their own release strategy

A 5% traffic canary works for the API, because a load balancer can split requests. A worker has no traffic to split: whatever version takes a message makes real financial changes. Release a worker in steps instead:

  1. Shadow processing: the new version reads a copy of the same events and writes its results only to a separate shadow table. It has no permission to change financial tables, publishes no events and sends no notifications.
  2. Compare: shadow results against the production results for the same events, for an agreed period. Any difference is investigated before going further.
  3. A controlled slice: route one provider, or a small set of loans, to the new version, with feature flags off for any new rule.
  4. Widen to all messages, keeping the old version ready to take over.
Before releaseAfter release
Artifact verified; required tests passedApplication health verified; smoke tests passed
Security checks reviewed; migration reviewedPayment ingestion and settlement processing validated
Deployment plan approved; rollback or recovery documentedReconciliation results checked; errors and latency watched
Dashboard ready; customer communication preparedCustomer acceptance recorded

Practice Plan the 1.4 to 1.5 release

Practical exercise

Exercise 11: a safe release plan

Version 1.5 adds a reconciliation rule, a schema addition, a dashboard update and a worker speed-up. Plan it, then simulate a failed deployment.

  1. The deployment plan and migration sequence.
  2. Verification tests for each change.
  3. The rollback or recovery plan.
Show a sample sequence
  • 1: expand migration adds the nullable column; 1.4 ignores it.
  • 2: deploy the 1.5 API as a canary at 5%, and the 1.5 worker in shadow mode with the new rule on, writing only to the shadow table.
  • 3: API checks pass at 25% and 100%; shadow results match production for two days, apart from the expected new-rule matches; then route one provider to the 1.5 worker, then all.
  • Failure: the 1.5 worker errors in shadow mode; it is stopped, production workers on 1.4 carry on, the column stays (harmless), no financial data changed.

2 questions

Check your understanding

1. Why use expand and contract for a column rename?
2. The container is healthy but search results are wrong. Is the release a success?
Answer every question to submit.

What you can do now

  • Choose a deployment strategy.
  • Plan expand-and-contract migrations.
  • Verify a release with business checks.