{
  "id": "redis/lua-script-stack-overflow",
  "signature": "ERR Error running script (call to f_<sha>): @user_script: <line>: Stack overflow in Lua script",
  "signature_zh": "运行脚本时出错（调用 f_<sha>）：@user_script: <line>：Lua 脚本堆栈溢出",
  "regex": "ERR Error running script \\(call to f_[a-f0-9]+\\): @user_script: \\d+: Stack overflow in Lua script",
  "domain": "redis",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Lua script exceeded the maximum call stack depth, typically due to deep recursion or excessive nested function calls.",
  "root_cause_type": "generic",
  "root_cause_zh": "Lua 脚本超过了最大调用堆栈深度，通常是由于深度递归或过多嵌套函数调用。",
  "versions": [
    {
      "version": "redis 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "redis 7.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "redis 6.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "redis 5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Redis does not expose a Lua stack size configuration; the limit is hardcoded.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The script execution mechanism is the same; the error is script logic, not caching.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Stack overflow is a call depth issue, not a memory allocation issue; more memory does not increase stack depth.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Refactor the Lua script to use iterative loops instead of recursion, e.g., replace recursive function with a while loop:\nwhile condition do ... end",
      "success_rate": 0.85,
      "how": "Refactor the Lua script to use iterative loops instead of recursion, e.g., replace recursive function with a while loop:\nwhile condition do ... end",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce the depth of nested function calls by flattening logic or using tail-recursive calls if Lua version supports (Redis Lua 5.1 does not).",
      "success_rate": 0.7,
      "how": "Reduce the depth of nested function calls by flattening logic or using tail-recursive calls if Lua version supports (Redis Lua 5.1 does not).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Refactor the Lua script to use iterative loops instead of recursion, e.g., replace recursive function with a while loop:\nwhile condition do ... end",
    "Reduce the depth of nested function calls by flattening logic or using tail-recursive calls if Lua version supports (Redis Lua 5.1 does not)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://redis.io/docs/latest/develop/interact/programmability/lua-api/",
  "official_doc_section": null,
  "error_code": "ERR",
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.75,
  "resolvable": "true",
  "first_seen": "2023-04-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}