StackExchange / StackExchange/StackExchange.Redis
Misleading documentation about the evaluation of server loaded Lua scripts
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 1.6k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
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 . 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 SHA-1 hash value, now the script itself is evaluated which works for our use caseXML 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the XML documentation for LoadedLuaScript::Evaluate() and LoadedLuaScript::EvaluateAsync(), then read their implementation to confirm the behavior after SCRIPT FLUSH and a missing script hash. Update both descriptions to explain the reload and first EVAL fallback, with later evaluations using EVALSHA.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, redis
- Domain
- databases
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100