ERR redis runtime_error ai_generated true

运行脚本时出错(调用 f_<sha>):@user_script:<行>:-BUSY Redis 正忙于运行脚本。您只能调用 SCRIPT KILL 或 SHUTDOWN NOSAVE。

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

其他格式: JSON · Markdown 中文 · English
85%修复率
90%置信度
1证据数
2023-10-05首次发现

版本兼容性

版本状态引入弃用备注
7.2.0 active
7.4.0 active
8.0.0 active

根因分析

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

English

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

generic

官方文档

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

解决方案

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

无效尝试

常见但无效的做法:

  1. 90% 失败

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

  2. 100% 失败

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