Version-gate LMOVE for Redis 6.0.x compatibility (Azure Cache for Redis)#176
Merged
Conversation
DequeueId.lua uses LMOVE (Redis 6.2+), which Azure Cache for Redis (pinned at 6.0.14) does not support, causing 'Unknown Redis command called from Lua script' errors on dequeue. Add RedisCapabilities.SupportsLMove (min version 6.2.0) and have RedisQueue select between the LMOVE script and a restored RPOPLPUSH fallback script at load time, invalidating the cached capability on reconnect. The RPOPLPUSH fallback script (DequeueId.Rpoplpush.lua) is the exact script used prior to #164 (verified via 'git show f77ee64^:...'); the Lua logic is byte-for-byte identical aside from an inconsequential UTF-8 BOM/trailing newline, which EmbeddedResourceLoader strips via StreamReader's default BOM detection. Verified locally: - Redis 6.0.20: full RedisQueueTests suite - 48 passed, 0 failed, 5 skipped, no LMOVE errors (RPOPLPUSH fallback confirmed selected) - Redis 7.4.9: dequeue passes, confirming LMOVE path still used on modern servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #174
Root cause
Scripts/DequeueId.luacallsLMOVE, which requires Redis 6.2+. PR #164 replaced the deprecatedRPOPLPUSHwithLMOVEwithout a version gate. Azure Cache for Redis is pinned at 6.0.14, so every dequeue throws:Confirmed directly against a live Azure Cache for Redis instance (server reports
v6.0.14).Fix
RedisCapabilities.SupportsLMove(min version6.2.0), mirroring the existingSupportsMsetexversion-gate pattern.RedisQueue.LoadScriptsAsyncnow selects theLMOVEscript on 6.2+ servers and falls back to a restoredRPOPLPUSHvariant (DequeueId.Rpoplpush.lua) on older servers.ConnectionMultiplexerOnConnectionRestored), same asSupportsMsetex.Audit: fallback script correctness
DequeueId.Rpoplpush.luawas verified against the exact pre-#164 script (git show f77ee64^:src/Foundatio.Redis/Scripts/DequeueId.lua). The Lua logic is byte-for-byte identical; the only difference is a UTF-8 BOM and trailing newline in the old file, both of which are inconsequential (EmbeddedResourceLoaderusesStreamReader, which strips a BOM by default, and other scripts in the repo already have mixed BOM/no-BOM and trailing-newline conventions).LMOVE src dst RIGHT LEFTis functionally identical toRPOPLPUSH src dst, so behavior is unchanged regardless of which variant is selected.Verification
RedisQueueTestssuite — 48 passed, 0 failed, 5 skipped, noLMOVEerrors. Since 6.0 has noLMOVE, this confirms theRPOPLPUSHfallback is correctly selected and functioning.LMOVEpath is still used (and preferred) on modern servers.Scope
This PR only addresses the
LMOVEincompatibility from #174. It does not touch the separately-reported cache expiration test flakiness (which is a test-latency issue against high-RTT connections, unrelated to Redis version support).