Description
Summary
Two Redis-compatibility gaps found while running real Ruby gems' test suites against kividb/kividb:v1.2.2-lua and Redis 8.10.3 side by side.
1. ZSCAN/SSCAN/HSCAN with COUNT 0 return ERR syntax error
Redis returns an empty result for a *SCAN on a key that does not exist before it looks at COUNT, and accepts COUNT 0 for SSCAN/HSCAN on existing keys too. KiviDB rejects all of these:
| Command | Redis 8.10.3 | KiviDB 1.2.2 |
|---|---|---|
ZSCAN missing 0 MATCH * COUNT 0 |
0, [] |
ERR syntax error |
ZSCAN existing 0 MATCH * COUNT 0 |
ERR syntax error |
ERR syntax error |
SSCAN existing 0 COUNT 0 |
0, [] |
ERR syntax error |
HSCAN existing 0 COUNT 0 |
0, {} |
ERR syntax error |
SCAN 0 COUNT 0 |
ERR syntax error |
ERR syntax error |
Real-world hit: sidekiq-unique-jobs 8.1.0 (used by Mastodon) sizes its ZSCAN by ZCARD, so with an empty digest set it sends ZSCAN uniquejobs:expiring_digests 0 match * count 0. On KiviDB the Sidekiq Web "delete all locks" action raises ERR syntax error; 3 of its specs fail (spec/sidekiq_unique_jobs/web_spec.rb:177, :200, :239), all passing on Redis. Captured with MONITOR on both servers.
2. Lua: implicit arg table in vararg functions (Lua 5.1 compatibility)
Redis's Lua 5.1 is built with LUA_COMPAT_VARARG, so a vararg function can read its arguments as the implicit table arg:
local function log_debug(...)
local result = ""
for _, v in ipairs(arg) do result = result .. " " .. tostring(v) end
return result
end
return log_debug("a", "b")Redis 8.10.3 runs this; KiviDB (Lua 5.4) fails with ERR Script attempted to access nonexistent global variable 'arg'. Seen in sidekiq-unique-jobs' test fixture spec/support/lua/shared/_common.lua (2 specs fail: script/client_spec.rb:22, script/scripts_spec.rb:47); the gem's shipped scripts use {...} and pass. Older scripts in the wild use this 5.0/5.1 idiom. Related to #747 (other Lua 5.4 number rules).
Results of the full suites (same host, both servers fresh)
| Suite | Redis 8.10.3 | KiviDB 1.2.2-lua |
|---|---|---|
| stoplight v5.8.3 (Mastodon's version) | 765 examples, 0 failures | 765 examples, 0 failures |
| sidekiq-scheduler v6.0.2 | 274 examples, 5 failures | 274 examples, the same 5 failures (Web UI, env) |
| sidekiq-unique-jobs v8.1.0 | 1069 examples, 1 failure (latency-sensitive) | 1069 examples, 6 failures (the same 1 + the 5 above) |
Environment
kividb/kividb:v1.2.2-lua (INFO redis_version:8.10.0) and redis:8 (8.10.3, --save ""), each started fresh; Ruby 3.4, suites run with --order defined from inside the server's network namespace; AWS CodeBuild linux x86_64.
Activity
murtazayusuf commentedon Nov 15, 2026
Correction to the table above, checked against real Redis 8.10.2 and 8.10.3 while fixing this (#828):
SSCAN existing 0 COUNT 0andHSCAN existing 0 COUNT 0answerERR syntax erroron Redis too, for every encoding. Only the missing-key rows differ from KiviDB: Redis looks the key up before reading the options, so a missing key answers0and an empty list whatever follows the cursor. #828 fixes that. The Lua implicitargpart stays open: it is created per call inside the Lua 5.1 VM, so it needs a VM change or #756.fix(scan): a missing key is an empty scan before COUNT is read; optio…
Merge pull request #854 from kividbio/fix/issue-820
fix(lua): a vararg function has the implicit arg table of Lua 5.1 (ki…