Skip to content

Misleading documentation about the evaluation of server loaded Lua scripts #2443

@SonnyRR

Description

@SonnyRR

Recently, I had to investigate an issue with server failovers which cleared the SHA-1 hash cache and prevented me from evaluating back-end cached lua scripts because the hashes themselves did not exist on the server. The StackExchange.Redis version was quite outdated and did not feature the improvements in v2.6.66 which change how loaded scripts were evaluated.

Instead of sending the SHA-1 hash value, now the script itself is evaluated which works for our use case. However, I was trying to replicate the issue we experienced in an isolated environment using a docker container. I was not able to reproduce the initial issue after I updated the library, whenever I rebooted the container. The XML documentation for the LoadedLuaScript::Evaluate() & LoadedLuaScript::EvaluateAsync() do not reference the new behavior and mislead me. Finally, I had to take a look at the source code in order to understand why after a SCRIPT FLUSH [SYNC|ASYNC] command, the loaded lua scripts were able to be evaluated even though the hashes were not present on the server.

ℹ️ Update: After looking through the command logs with MONITOR, seems like if a previously loaded script's hash is not found on the server - it will be reloaded with SCRIPT LOAD. However, I'm seeing that it's evaluated with the EVAL command on the first evaluation, after the reload operation. Any subsequent evaluation uses EVALSHA.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions