ERR redis runtime_error ai_generated true

ERR Error running script (call to f_<sha>): @user_script: <line>: -BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.

ID: redis/lua-script-deadlock-timeout

Also available as: JSON · Markdown · 中文
85%Fix Rate
90%Confidence
1Evidence
2023-10-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.2.0 active
7.4.0 active
8.0.0 active

Root Cause

Lua script exceeded lua-time-limit (default 5s), blocking all other commands; only SCRIPT KILL or SHUTDOWN NOSAVE can recover.

generic

中文

Lua 脚本超过 lua-time-limit(默认 5 秒),阻塞所有其他命令;只能通过 SCRIPT KILL 或 SHUTDOWN NOSAVE 恢复。

Official Documentation

https://redis.io/docs/manual/programmability/eval-intro/

Workarounds

  1. 90% success Kill the script: redis-cli SCRIPT KILL. This works if the script has not performed any write operations. If it has written, use SHUTDOWN NOSAVE instead.
    Kill the script: redis-cli SCRIPT KILL. This works if the script has not performed any write operations. If it has written, use SHUTDOWN NOSAVE instead.
  2. 80% success Prevent future occurrences by optimizing Lua scripts: use local variables, avoid long loops, and set lua-time-limit higher (e.g., CONFIG SET lua-time-limit 10000).
    Prevent future occurrences by optimizing Lua scripts: use local variables, avoid long loops, and set lua-time-limit higher (e.g., CONFIG SET lua-time-limit 10000).

中文步骤

  1. 终止脚本:redis-cli SCRIPT KILL。如果脚本未执行任何写操作,这有效。如果已写入,请改用 SHUTDOWN NOSAVE。
  2. 通过优化 Lua 脚本防止未来发生:使用局部变量、避免长循环,并设置更高的 lua-time-limit(例如 CONFIG SET lua-time-limit 10000)。

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Restarting the Redis server with SHUTDOWN (without NOSAVE) will fail because the script blocks the SHUTDOWN command itself; only SHUTDOWN NOSAVE works.

  2. 100% fail

    Sending any other command (like PING) will fail because all commands are blocked; only SCRIPT KILL or SHUTDOWN NOSAVE are allowed.