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

- **ID:** `redis/lua-script-deadlock-timeout`
- **领域:** redis
- **类别:** runtime_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.2.0 | active | — | — |
| 7.4.0 | active | — | — |
| 8.0.0 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — Restarting the Redis server with SHUTDOWN (without NOSAVE) will fail because the script blocks the SHUTDOWN command itself; only SHUTDOWN NOSAVE works. (90% 失败率)
- **** — Sending any other command (like PING) will fail because all commands are blocked; only SCRIPT KILL or SHUTDOWN NOSAVE are allowed. (100% 失败率)
