# 错误：获取状态锁失败：条件检查异常：条件请求失败

- **ID:** `terraform/terraform-state-lock-unlock-failed`
- **领域:** terraform
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

另一个 Terraform 进程持有状态锁，或之前的锁未正确释放。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform v1.6 | active | — | — |
| Terraform v1.7 | active | — | — |
| Terraform v1.8 | active | — | — |
| AWS Provider v5.0+ | active | — | — |

## 解决方案

1. ```
   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.
   ```
2. ```
   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>"}}'
   ```

## 无效尝试

- **** — Deleting the lock file can corrupt state if another process is still running, leading to state conflicts. (70% 失败率)
- **** — 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. (50% 失败率)
- **** — The lock may still be held by the previous process, and restarting will not release it automatically. (60% 失败率)
