ERM
redis
runtime_error
ai_generated
partial
ERR LUA script deadlock detected: script <sha> blocked for <seconds> seconds
ID: redis/lua-script-deadlock-detected
78%Fix Rate
88%Confidence
1Evidence
2023-05-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 6.0 | active | — | — | — |
| 7.0 | active | — | — | — |
| 7.2 | active | — | — | — |
Root Cause
A Lua script entered an infinite loop or blocked on a resource (e.g., Redis.call inside a loop), exceeding the lua-time-limit and triggering a deadlock warning.
generic中文
Lua 脚本进入无限循环或在资源上阻塞(例如,循环内的 Redis.call),超过了 lua-time-limit,触发死锁警告。
Official Documentation
https://redis.io/docs/latest/programmability/eval-intro/Workarounds
-
85% success Run 'SCRIPT KILL' if the script has not performed any writes (check with 'SCRIPT DEBUG'). If writes occurred, use 'SHUTDOWN NOSAVE' to stop Redis.
Run 'SCRIPT KILL' if the script has not performed any writes (check with 'SCRIPT DEBUG'). If writes occurred, use 'SHUTDOWN NOSAVE' to stop Redis.
-
90% success Add a loop counter or use 'redis.setresp(3)' to limit iterations. Example: 'local i = 0; while i < 1000 do redis.call("PING"); i = i + 1 end'.
Add a loop counter or use 'redis.setresp(3)' to limit iterations. Example: 'local i = 0; while i < 1000 do redis.call("PING"); i = i + 1 end'.
中文步骤
如果脚本未执行任何写入(使用 'SCRIPT DEBUG' 检查),运行 'SCRIPT KILL'。如果已写入,使用 'SHUTDOWN NOSAVE' 停止 Redis。
添加循环计数器或使用 'redis.setresp(3)' 限制迭代次数。示例:'local i = 0; while i < 1000 do redis.call("PING"); i = i + 1 end'。
Dead Ends
Common approaches that don't work:
-
40% fail
Only works if script hasn't written data; otherwise, Redis forces shutdown.
-
70% fail
Masks the problem; script may still hang indefinitely, blocking other operations.
-
60% fail
Causes downtime and potential data loss; does not fix the script logic.