`terraform apply` in CI fails with "Error acquiring the state lock: ConditionalCheckFailedException" and shows a lock from a pipeline run that was cancelled two hours ago.

BeginnerTroubleshootingPipeline outages
Answer

Likely causes → A run was killed (cancelled job, runner died, timeout) before Terraform released its lock in the backend, so the lock entry is orphaned.

Diagnose → The error prints the lock ID, who holds it and when. Confirm nothing is actually running: check CI for in-progress jobs on the same workspace and ask in the team channel.

Fix → Only once you're sure no apply is running:

terraform force-unlock <LOCK_ID>

Then run terraform plan to check whether the interrupted apply left partial changes.

Prevent → Serialize Terraform jobs per workspace (concurrency: group in GitHub Actions, disableConcurrentBuilds() in Jenkins), give runs enough timeout, and handle SIGTERM gracefully (Terraform releases the lock on a clean interrupt).

All Real-World Interview questions Roadmap: Interview readiness

More on Pipeline outages