redis scripting_error ai_generated true

BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.

ID: redis/busy-script-running

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7 active

Root Cause

A Lua script or Redis function is running longer than lua-time-limit (default 5s), blocking all other commands.

generic

Workarounds

  1. 92% success Use SCRIPT KILL to terminate the running script
    redis-cli SCRIPT KILL  # only works if the script has NOT performed any writes yet

    Sources: https://redis.io/docs/latest/operate/oss_and_stack/management/

  2. 75% success If script has written data, use SHUTDOWN NOSAVE only as last resort
    SCRIPT KILL fails after writes; SHUTDOWN NOSAVE + restart loses unsaved changes. Consider the tradeoff.
  3. 88% success Fix the Lua script to avoid long execution
    Break large operations into batches; use SCAN instead of KEYS; avoid O(n) operations on large sets

Dead Ends

Common approaches that don't work:

  1. Use SHUTDOWN NOSAVE to stop the script 90% fail

    SHUTDOWN terminates the entire Redis server; all connected clients lose their connection and unsaved data is lost

  2. Increase lua-time-limit to avoid the BUSY error 72% fail

    Longer limit means longer blocking periods; all other clients are frozen while Lua executes