# 错误：获取状态锁失败：ConditionalCheckFailedException：条件请求失败：ProvisionedThroughputExceededException：速率超限

- **ID:** `terraform/state-lock-dynamodb-throttling`
- **领域:** terraform
- **类别:** resource_error
- **错误码:** `ProvisionedThroughputExceededException`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

用于状态锁定的 DynamoDB 表因请求速率过高而受到限流，超出了预置的读写容量。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform 1.5.0 | active | — | — |
| Terraform 1.6.0 | active | — | — |
| Terraform 1.7.0 | active | — | — |

## 解决方案

1. ```
   增加 DynamoDB 表的预置读写容量单元以处理峰值负载。如果工作负载不可预测，切换到按需容量模式。
   ```
2. ```
   通过将 terraform 命令包装在带有指数退避的 bash 脚本中，实现客户端重试逻辑。
   ```
3. ```
   在高峰时段减少 terraform apply/plan 操作的频率，或错开多个 CI/CD 管道以避免并发锁尝试。
   ```

## 无效尝试

- **** — The lock acquisition failed due to throttling, not because the lock is held. Force-unlock doesn't address the throughput issue. (90% 失败率)
- **** — Deleting the table removes all state lock items but also any existing locks. Recreating with default settings still has low throughput. (80% 失败率)
- **** — Terraform's retry mechanism is for provider operations, not for state lock acquisition. The lock mechanism is internal and not configurable. (95% 失败率)
