Update Redis Cluster compatibility docs#1169
Open
ranmori wants to merge 1 commit into
Open
Conversation
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.
`
Redis Cluster Compatibility — verified findings (v0.26.0)
I went through
internal/rdb/rdb.goandinternal/rdb/inspect.godirectly rather than relying on the AI summary linked above, to confirm the pattern and scope it precisely.1. Which scripts are affected, and why
Redis Cluster routes a script to a node based on the hash slot of the keys declared in the
KEYStable passed toEVAL/EVALSHA. If a script touches an additional key that it builds itself by concatenating strings fromARGV(rather than receiving it viaKEYS), that key is invisible to the cluster's routing/slot-check step. If that self-built key doesn't happen to hash to the same slot as the declaredKEYS, Redis raisesCROSSSLOT Keys in request don't hash to the same slotat execution time.16 of the 43 Lua scripts in the codebase do this — they take an id/state/group name via
ARGVand concatenate it directly onto a key prefix inside the script body:instead of the cluster-safe form, which is:
2. Affected functionality (public
Inspectormethods)Not affected: core enqueue/dequeue/done/retry paths (
enqueueCmd,dequeueCmd,doneCmd,retryCmd,scheduleCmd, etc.) all pass their keys throughKEYS, notARGVconcatenation. So basic task processing works fine on Redis Cluster — it's specifically the introspection and management surface (theInspectorAPI, and by extension the CLI/Web UI, which are built on top of it) that's at risk.3. Practical impact
Inspectormethods, the CLI (asynqtool), or the Web UI to inspect, run, archive, or delete individual tasks/groups, those calls can fail withCROSSSLOTerrors on a real multi-node cluster, depending on where the relevant keys land.redis-cli --clusterwith one node, only multi-node.Correction to the thread's existing (Copilot-derived) answer
I traced where those
ARGV-concatenated key prefixes actually come from (base.TaskKeyPrefix,base.QueueKeyPrefix,base.GroupKeyPrefixininternal/base/base.go), and every one of them is built as:All asynq keys are already hash-tagged on
{qname}. Redis Cluster only hashes the substring between{and}when computing a key's slot — soasynq:{q}:t:123andasynq:{q}:archivedland on the exact same slot regardless of what comes after the tag. In every affected script, theARGV-built key and theKEYS-declared keys in the same call are constructed from the sameqname, so they're always in the same hash tag and therefore the same slot.Practical conclusion: the
ARGV .. idpattern is a real style inconsistency (and the scripts would break if the hash-tag discipline inbase.gowere ever violated), but for the current codebase it does not appear to causeCROSSSLOTerrors — the existing{qname}tagging already provides the safety net. I checkedRemoveQueue,forward, andArchiveTaskspecifically for any cross-queue key mixing and found none; every script'sARGVkeys resolve to the same tag as its declaredKEYS.What I'd actually propose in the PR
- Correct the community answer above ("CROSSSLOT risk") with this analysis — it's a
more useful answer to the three original questions than "these scripts are broken."
- Update the one-line README caveat to be specific instead of vague: name the
invariant that makes it safe (
- Optionally: a lint/test that asserts every
`{qname}hash-tagging) so future contributors don't accidentally break it by building a key from two different queues' data in one script, which would triggerCROSSSLOT.ARGV-built key prefix used inside a Lua script matches the queue's hash tag — cheap insurance against regression.