Improve Deckard integration with Redis Clusters#66
Draft
Conversation
Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve Deckard integration with Redis Clusters
Improve Deckard integration with Redis Clusters
Jun 5, 2025
Member
|
@copilot re-run checks so I can check if tests pass |
Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
Contributor
Author
cezar-tech
reviewed
Jun 6, 2025
Comment on lines
+77
to
+78
| redis-cluster-node-1:7000 | ||
| redis-cluster-node-2:7001 |
Collaborator
There was a problem hiding this comment.
can you make it easier to assimilate by starting the node count from 0 so that it conforms to the ports final digits ?
|
|
||
| ### Redis Cluster | ||
| Keys use hash tags to ensure co-location: | ||
| - `deckard:queue:{myqueue}` |
Collaborator
There was a problem hiding this comment.
since you are using {myqueue} to refer to a hash tag, this templated name should be improved to be more mnemonic dont you think so ?
call it {clusterhash} for example.
and change this terminology in all the documentations you have made.
Comment on lines
+599
to
+606
| var redisKey string | ||
| if cache.clusterMode { | ||
| redisKey = fmt.Sprint("deckard:{", key, "}") | ||
| } else { | ||
| redisKey = fmt.Sprint("deckard:", key) | ||
| } | ||
|
|
||
| cmd := cache.Client.Get(context.Background(), redisKey) |
Collaborator
There was a problem hiding this comment.
this is repeated twice, maybe transform it into a method ?
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.
This PR implements Redis Cluster support for Deckard while maintaining full backward compatibility with single-node Redis deployments.
Problem
Deckard's Lua scripts access multiple keys that may hash to different slots in a Redis Cluster, causing script execution to fail. Redis Cluster requires all keys accessed by a Lua script to be on the same hash slot for atomic operations.
Solution
Implemented a hash tag strategy that ensures all queue-related keys land on the same Redis Cluster slot:
Before (Single-node only):
deckard:queue:myqueuedeckard:queue:myqueue:tmpdeckard:queue:myqueue:lock_ackAfter (Cluster-compatible):
deckard:queue:{myqueue}deckard:queue:{myqueue}:tmpdeckard:queue:{myqueue}:lock_ackThe
{myqueue}hash tag ensures atomic operations across all related keys.Changes
Configuration Support
redis.cluster.modeandredis.cluster.addressesconfiguration optionsredis.Clientandredis.ClusterClientvia unified interfaceDECKARD_REDIS_CLUSTER_MODE,DECKARD_REDIS_CLUSTER_ADDRESSESKey Naming Strategy
Testing Infrastructure
Documentation
Configuration Examples
Single-node (default, unchanged):
Redis Cluster (new):
Backward Compatibility
Testing
Run cluster integration tests:
Fixes #13.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.