Skip to content

Handle redis NOSCRIPT errors #182

@lewisfzhang

Description

@lewisfzhang

Background: Rate limiter library throwing redis.exceptions.NoScriptError: No matching script. Please use EVAL during Redis failover

This is likely due to use of Redis scripts for the standard implementation of Redis bucket puts

Per Redis protocol, Redis script cache is always volatile. It isn't considered as a part of the database and is not persisted. The cache may be cleared when the server restarts, during fail-over when a replica assumes the master role. That means that cached scripts are ephemeral, and the cache's contents can be lost at any time.

In case of getting this error on runtime, the application should first re-load it with SCRIPT LOAD and then call EVALSHA once more to run the cached script by its SHA1 sum. Most of Redis' clients already provide utility APIs for doing that automatically. Please see register_script method and scripting docs for redis-py library.

Another alternative is you can use the SCRIPT EXISTS command first to see if a given SHA-1 digest represents a cached script.

https://redis.io/docs/latest/develop/interact/programmability/eval-intro/
https://redis.io/blog/bullet-proofing-lua-scripts-in-redispy/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions