terraform
resource_error
ai_generated
true
错误:获取状态锁失败:条件检查异常:条件请求失败
Error: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed: The conditional request failed
ID: terraform/terraform-state-lock-unlock-failed
85%修复率
85%置信度
1证据数
2023-08-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.6 | active | — | — | — |
| Terraform v1.7 | active | — | — | — |
| Terraform v1.8 | active | — | — | — |
| AWS Provider v5.0+ | active | — | — | — |
根因分析
另一个 Terraform 进程持有状态锁,或之前的锁未正确释放。
English
Another Terraform process holds the state lock, or a previous lock was not released properly.
官方文档
https://developer.hashicorp.com/terraform/language/state/locking解决方案
-
Force unlock the state using 'terraform force-unlock <lock_id>' after verifying no other Terraform process is running. First, run 'terraform plan' to see if the lock is stale.
-
If using S3 backend, manually delete the lock file from the DynamoDB table using AWS CLI: 'aws dynamodb delete-item --table-name <table-name> --key {"LockID":{"S":"<lock-id>"}}'
无效尝试
常见但无效的做法:
-
70% 失败
Deleting the lock file can corrupt state if another process is still running, leading to state conflicts.
-
50% 失败
Using a wrong lock ID will not release the lock, and may cause additional errors if the lock is actually held by a different process.
-
60% 失败
The lock may still be held by the previous process, and restarting will not release it automatically.