{
  "id": "terraform/terraform-state-push-lock-expired",
  "signature": "Error: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed: The conditional request failed because the lock has expired",
  "signature_zh": "错误：获取状态锁时出错：ConditionalCheckFailedException：条件请求失败：条件请求失败，因为锁已过期",
  "regex": "Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed: The conditional request failed because the lock has expired",
  "domain": "terraform",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A state lock was acquired but expired (e.g., due to a long-running operation or stale lock), and Terraform's conditional update check failed because the lock item's version no longer matches.",
  "root_cause_type": "generic",
  "root_cause_zh": "状态锁已被获取但已过期（例如，由于长时间运行的操作或过时的锁），并且 Terraform 的条件更新检查失败，因为锁项的版本不再匹配。",
  "versions": [
    {
      "version": "1.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Manually delete the DynamoDB lock item using AWS CLI without checking who holds the lock.",
      "why_fails": "This can cause state corruption if another Terraform process is still running; it should only be done after confirming no active operations.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Re-run terraform apply immediately without force-unlocking.",
      "why_fails": "The expired lock still exists in DynamoDB, so the new attempt will also fail with the same error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change the backend configuration to use a different DynamoDB table.",
      "why_fails": "This creates a new lock table but doesn't resolve the stale lock in the original table; state operations will still fail.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Force unlock the state using the lock ID: terraform force-unlock <LOCK_ID>. First, get the lock ID from the error message or by inspecting the DynamoDB table: aws dynamodb get-item --table-name terraform-lock --key '{\"LockID\": {\"S\": \"<state-file-path>\"}}' --projection-expression \"LockID, Digest\". Then run terraform force-unlock <LOCK_ID>.",
      "success_rate": 0.9,
      "how": "Force unlock the state using the lock ID: terraform force-unlock <LOCK_ID>. First, get the lock ID from the error message or by inspecting the DynamoDB table: aws dynamodb get-item --table-name terraform-lock --key '{\"LockID\": {\"S\": \"<state-file-path>\"}}' --projection-expression \"LockID, Digest\". Then run terraform force-unlock <LOCK_ID>.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the lock ID is not available, manually delete the lock item from DynamoDB after confirming no Terraform process is running: aws dynamodb delete-item --table-name terraform-lock --key '{\"LockID\": {\"S\": \"<state-file-path>\"}}'",
      "success_rate": 0.85,
      "how": "If the lock ID is not available, manually delete the lock item from DynamoDB after confirming no Terraform process is running: aws dynamodb delete-item --table-name terraform-lock --key '{\"LockID\": {\"S\": \"<state-file-path>\"}}'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the lock timeout in the backend configuration to prevent future expiration: backend \"s3\" { ... dynamodb_table = \"terraform-lock\" lock_timeout = \"5m\" }",
      "success_rate": 0.8,
      "how": "Increase the lock timeout in the backend configuration to prevent future expiration: backend \"s3\" { ... dynamodb_table = \"terraform-lock\" lock_timeout = \"5m\" }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用锁 ID 强制解锁状态：terraform force-unlock <LOCK_ID>。首先从错误消息中获取锁 ID，或通过检查 DynamoDB 表：aws dynamodb get-item --table-name terraform-lock --key '{\"LockID\": {\"S\": \"<state-file-path>\"}}' --projection-expression \"LockID, Digest\"。然后运行 terraform force-unlock <LOCK_ID>。",
    "如果锁 ID 不可用，请在确认没有 Terraform 进程运行后手动从 DynamoDB 删除锁项：aws dynamodb delete-item --table-name terraform-lock --key '{\"LockID\": {\"S\": \"<state-file-path>\"}}'",
    "在后端配置中增加锁超时时间以防止将来过期：backend \"s3\" { ... dynamodb_table = \"terraform-lock\" lock_timeout = \"5m\" }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.hashicorp.com/terraform/language/settings/backends/s3#dynamodb_table",
  "official_doc_section": null,
  "error_code": "ConditionalCheckFailedException",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2024-05-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}