Engineering Practice

What happens when a deployment fails?

A failed deployment should stop automatically, preserve diagnostic evidence and either restore the last known-good release or move forward with a tested repair. The safe choice depends on whether data or external contracts have changed, so rollback capability must be designed and rehearsed before release rather than improvised during failure.

Updated 4 min read

Failure must have a defined meaning

A deployment can fail while building an artefact, applying infrastructure, changing a database, starting processes or serving real traffic. Each stage needs an observable success condition and timeout. A pipeline reporting success only proves its commands exited cleanly; it does not prove the application can authenticate, reach dependencies or process a representative transaction. Health checks should distinguish process liveness from readiness, while post-deployment verification tests critical paths. When a gate fails, automation stops further promotion and captures versions, logs and changes without exposing secrets.

The first operational decision is whether users are affected. If production remains on the old version, the failed candidate can be isolated and investigated without incident-level urgency. If traffic has reached a broken release, incident command takes priority over debugging the ideal fix. One person coordinates decisions and communication while engineers restore service. Changes made under pressure are recorded. A known-good artefact is promoted through the same controlled mechanism as any release; rebuilding old source during an incident risks pulling different dependencies or configuration.

Rollback is an architectural property

Application binaries are usually easy to replace. Data changes, queued messages and calls to external systems may not be reversible. Database migrations should therefore favour backwards-compatible expansion: add new structures, deploy code that can use both forms, migrate data, then remove obsolete structures after confidence. Destructive changes do not accompany the first dependent release. Event schemas and APIs need compatible evolution for the same reason. Where a transaction has escaped to a payment or fulfilment provider, a compensating business action may be required rather than technical rollback.

  • Promote immutable, identified artefacts rather than rebuilding per environment.
  • Automate readiness and representative post-deployment checks.
  • Keep configuration changes versioned and independently reversible.
  • Design database and message changes for mixed-version operation.
  • Define stop, rollback and escalation authority in the release runbook.

Limit exposure before full promotion

Rolling, blue-green and canary strategies reduce different risks but do not eliminate them. A canary needs signals sensitive enough to detect failure in limited traffic. Blue-green deployment simplifies traffic switching but both environments must share compatible data and configuration. Feature flags can separate deployment from activation, provided defaults are safe, access is controlled and stale flags are removed. Monitor technical signals and business invariants such as duplicate submissions or unbalanced processing. A healthy CPU graph can coexist with corrupted workflow state.

Data integrity decides the response

Before rollback, determine whether the new version wrote data the old version cannot understand. Check migration status, queue consumers, scheduled jobs and external side effects. Pause writers where necessary to prevent divergence. Restore from backup only when corruption cannot be repaired more safely; restoration loses changes after the recovery point and therefore requires a business decision. Point-in-time recovery procedures need regular exercises and application-level validation. A database reporting a successful restore does not establish that references, files and external records agree.

Communicate facts and decisions

Incident updates should state user impact, current containment, next decision point and known limitations without speculation. Internal stakeholders need an accountable channel; customers may need status communication appropriate to the service and obligation. Preserve a timeline from pipeline, infrastructure and application records. After recovery, reconcile partially processed work and confirm delayed jobs, notifications or integrations. Closing the technical alert before business state is reconciled leaves latent errors that emerge later as duplicate charges, missing records or unexplained reports.

Learn without weakening release control

A blameless review reconstructs conditions and identifies why controls failed to prevent or limit impact. Actions should improve detection, compatibility, tests, runbooks or architecture, with owners and verification. Simply requiring another approval often adds delay without information. Replay the failed path in a safe environment and add the smallest reliable regression check. Track repeated causes across incidents. The objective is not zero failed candidates; frequent safe rejection before user impact can indicate effective delivery controls. The objective is bounded failure with a practised route back to trustworthy service. Review actions are complete only when the changed control has been exercised and its evidence inspected.

FAQ

Related questions

Should every failed deployment be rolled back?

No. If no user traffic reached it, stopping may be enough; if irreversible data changes occurred, a tested forward repair can be safer than rollback.

Can database migrations be rolled back?

Some can, but destructive reversals can lose data. Backwards-compatible staged migrations are safer than relying on down scripts during an incident.

What is a known-good release?

It is the exact immutable artefact and configuration previously verified in production or an equivalent controlled environment, retained so it can be promoted without rebuilding.

Put the question in context.

A general answer only goes so far. Describe the system you are working with and you will get one that accounts for it.