What this thread does
Do first: match the Error acquiring the state lock metadata to the owning pipeline and confirm that run has stopped before using terraform force-unlock LOCK_ID.
Short answer
As of November 2026, 1.17.2 (November 11, 2026) current state-locking documentation says force-unlock is for your own lock when automatic unlocking failed. A lock's age alone is insufficient; unlocking an active writer allows concurrent state changes (locking).
Choose / don't choose
- Wait: choose while the owner is active or uncertain; don't force-unlock because another pipeline is inconveniently slow.
- Force-unlock: choose after confirming an abandoned lock from your stopped run; don't unlock a different workspace or a live owner's lock.
- Backend repair: choose when permission or storage errors prevent lock handling; don't bypass concurrency protection with lock=false (locking, plan options).
Not for: Terraform CLI patch upgrades; see terraform-1-17-1-patch-fmt-data-loss-destroy-policy-stacks-results.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
-lock-timeout=DURATION | Example 5m for an acceptable CI wait budget; retry acquisition for that duration, then fail | Terraform plan, current docs | plan |
-lock | Keep locking enabled; do not pass -lock=false on a shared workspace | Terraform state operations that support locking | plan, locking |
terraform force-unlock LOCK_ID | Manually unlock the state for the defined configuration; pass its lock ID | Remote backend recovery | command |
force-unlock -force | Omit for interactive recovery; flag only suppresses confirmation | Terraform CLI | command |
use_lockfile | true to enable S3 locking; default false; preserve the actual backend's locking configuration during investigation | S3 backend only | backend |
The timeout is a chosen pipeline budget, not a lock expiry or permission to unlock after five minutes. Some backends do not support locking; local state cannot be unlocked by another process (locking, force-unlock).
Order of operations
1. Preserve the error's ID, Path, Operation, Who, Version and Created metadata privately. Match its backend path and workspace to the current root configuration, then map the owner/time to CI run records and runner/process status. The report by veben shows these diagnostic fields; they describe a lock, not proof that its owner has died. 2. Stop new competing runs. If the owner is active, let it finish or use the pipeline's controlled cancellation and wait until its process stops. A canceled UI job can leave a runner alive. Unknown ownership stays on the wait/investigate branch. 3. For a legitimate busy run, retry acquisition with a bounded command such as terraform plan -lock-timeout=5m. Do not disable locking; configure CI serialization per backend/workspace as the normal operating policy (plan). 4. Only after confirming your run is gone and automatic unlock failed, use terraform force-unlock LOCK_ID from the matching initialized configuration and workspace, then confirm the command's prompt. The ID targets a particular lock; it is not the state filename or a provider lock-file identifier (force-unlock, locking). 5. Re-plan with locking enabled and review any partial infrastructure changes before retrying an interrupted apply. An unlock removes a lock; it does not undo the previous run or authorize the old operation to be repeated blindly (force-unlock semantics).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
ConditionalCheckFailedException | The reported conditional request failed while acquiring the state lock | Inspect the lock metadata and owner first, then wait or remove only your abandoned lock | veben report, locking |
Error acquiring the state lock | The conditional request failed in the historical lock report | Read the full backend error; wait for a live owner, repair permissions when implicated, or force-unlock the exact abandoned ID | locking, S3 locking/permissions |
The old DynamoDB error does not describe every current S3 lock. Current S3 docs deprecate DynamoDB locking and support opt-in S3 lockfiles; a backend migration is a separate operation, not an incident unlock (S3).
Evidence and limits
- The linked report by veben was asked June 4, 2020.
- Force-unlock is only for your own lock when automatic unlocking failed (locking).
- The backend, lock owner and pipeline status are unknown. No safe stale-age threshold or universal timeout can be inferred.
- A lock ID from an old log may have been replaced; recheck the current owner/ID immediately before recovery.
Checked
2026-11-12; Terraform 1.17.2 release, current locking/force-unlock/plan/S3 references and veben's June 4, 2020 report read. No backend or Terraform commands executed.
Started from a post by @HashiCorp, packaged by the editor. Original post