{
  "id": "redis/lua-script-oom",
  "signature": "ERR Error running script (call to f_<sha>): @user_script: <line>: -OOM command not allowed when used memory > 'maxmemory'",
  "signature_zh": "ERR 运行脚本错误（调用 f_<sha>）：@user_script: <行>: -OOM 当已用内存超过 'maxmemory' 时不允许执行命令",
  "regex": "ERR Error running script \\(call to f_[a-f0-9]+\\): @user_script: \\d+: -OOM command not allowed when used memory > 'maxmemory'",
  "domain": "redis",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A Lua script attempted to execute a write command while the Redis instance exceeded its maxmemory limit, triggering the out-of-memory policy.",
  "root_cause_type": "generic",
  "root_cause_zh": "Lua 脚本尝试执行写命令，但 Redis 实例已超过 maxmemory 限制，触发了内存不足策略。",
  "versions": [
    {
      "version": "Redis 6.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Redis 7.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Redis 7.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "SCRIPT KILL only stops the script, but the memory pressure remains; the script will fail again on next execution.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Blindly increasing maxmemory can lead to swap usage or OOM killer on the server; it does not fix the script's memory consumption.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling eviction can cause Redis to crash with OOM if memory is exhausted; it is not a safe workaround.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Reduce script memory usage by batching operations: use redis.pcall with smaller key sets and avoid storing large intermediate results in Lua tables.",
      "success_rate": 0.85,
      "how": "Reduce script memory usage by batching operations: use redis.pcall with smaller key sets and avoid storing large intermediate results in Lua tables.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase maxmemory and enable an eviction policy: CONFIG SET maxmemory 2gb; CONFIG SET maxmemory-policy allkeys-lru. This allows Redis to free memory before the script runs.",
      "success_rate": 0.9,
      "how": "Increase maxmemory and enable an eviction policy: CONFIG SET maxmemory 2gb; CONFIG SET maxmemory-policy allkeys-lru. This allows Redis to free memory before the script runs.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use MEMORY USAGE command to identify large keys and delete or archive them before rerunning the script.",
      "success_rate": 0.8,
      "how": "Use MEMORY USAGE command to identify large keys and delete or archive them before rerunning the script.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Reduce script memory usage by batching operations: use redis.pcall with smaller key sets and avoid storing large intermediate results in Lua tables.",
    "Increase maxmemory and enable an eviction policy: CONFIG SET maxmemory 2gb; CONFIG SET maxmemory-policy allkeys-lru. This allows Redis to free memory before the script runs.",
    "Use MEMORY USAGE command to identify large keys and delete or archive them before rerunning the script."
  ],
  "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": "ERM",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}