-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Introduce request & response policy support #4411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…cCommandFlagsRegistry
…tor interface The logic on how command should be routed should be decided in CommandExecutor based on command request/response policy and client configuration
412a50f to
d03b783
Compare
a957982 to
0db6694
Compare
bd6ee0f to
0fdcacf
Compare
Test Results 287 files + 2 287 suites +2 12m 18s ⏱️ +14s Results for commit 6bfffe6. ± Comparison against base commit af6454d. This pull request removes 33 and adds 88 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces comprehensive support for Redis cluster request/response policies, enabling intelligent routing of keyless commands and multi-shard operations. The changes implement Redis's command tips specification for cluster deployments.
Changes:
- Added
RequestPolicyandResponsePolicyenums with intelligent routing and aggregation strategies - Implemented keyless command execution with round-robin distribution across cluster nodes
- Added multi-shard command support with automatic key-based slot splitting
- Removed
ClusterCommandArgumentsin favor of unified hash slot tracking inCommandArguments
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Test files (multiple) | Updated from broadcastCommand() to executeCommand() - proper API migration |
| ClusterReplyAggregatorTest.java | Comprehensive tests for new aggregation utility |
| ClusterCommandExecutorTest.java | Extensive tests for keyless and multi-shard execution |
| ClusterCommandObjectsTest.java | Tests for hash slot grouping logic |
| CommandFlagsRegistryGenerator.java | Extracts request/response policies from Redis command metadata |
| ClusterCommandExecutor.java | Core policy-based routing implementation |
| ClusterReplyAggregator.java | Response aggregation utility (SUM, MIN, MAX, AND, OR, etc.) |
| CommandArguments.java | Added hash slot tracking with caching |
| ClusterCommandObjects.java | Multi-shard command splitting methods |
| RedisClusterClient.java | Multi-shard method overrides (del, mget, mset, etc.) |
| StaticCommandFlagsRegistry*.java | Policy storage and lookup |
| UnifiedJedis.java | Removed broadcast config, deprecated sendCommand methods |
| ClusterCommandArguments.java | Deleted - functionality merged into CommandArguments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| slotToElements.computeIfAbsent(slot, k -> new ArrayList<>()).add(key); | ||
| if (keyValueMode) { | ||
| slotToElements.get(slot).add(keysOrKeysValues[i + 1]); |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This array access might be out of bounds, as the index might be equal to the array length.
This PR introduces support for request/response policies in Redis cluster command execution, enabling proper handling of keyless commands and multi-shard operations. The changes implement Redis's command tips specification for cluster deployments, allowing the Jedis client to intelligently route commands to appropriate nodes and aggregate responses based on command-specific policies.
Key Changes
Core Infrastructure
CommandFlagsRegistry: AddedRequestPolicyandResponsePolicyenums to define how commands should be routed and how responses should be aggregated in cluster modeStaticCommandFlagsRegistry: Extended to store and retrieve request/response policies alongside command flagsCommandArguments: AddedisKeyless()method andaddHashSlotKey()for special cases like KEYS/SCAN commands; removedClusterCommandArgumentsin favor of unified hash slot trackingCluster Command Execution
ClusterCommandExecutor:executeKeylessCommand()with round-robin distribution across cluster nodesexecuteMultiShardCommand()for commands that span multiple hash slots (DEL, MGET, MSET, etc.)broadcastCommand()to support both primary-only and all-nodes executionexecuteCommand()ClusterReplyAggregator: New utility class implementing response aggregation strategies (SUM, MIN, MAX, LOGICAL_AND, LOGICAL_OR, ALL_SUCCEEDED, ONE_SUCCEEDED)Multi-Shard Command Support
ClusterCommandObjects: Added methods to split multi-key commands by hash slot:delMultiShard(),existsMultiShard(),mgetMultiShard(),msetMultiShard()touchMultiShard(),unlinkMultiShard(),msetexMultiShard()groupArgumentsByKeyHashSlot()andgroupArgumentsByKeyValueHashSlot()Code Generation
CommandFlagsRegistryGenerator: Updated to extractrequest_policyandresponse_policyfrom Redis command tips, with support for manual overridesException Handling
UnsupportedAggregationExceptionfor invalid aggregation operationsClusterAggregationExceptionfor aggregation failuresImpact
DBSIZE,CONFIG GET) are now properly distributed across cluster nodes using round-robinDEL,MGET,MSET) with keys in different hash slots are automatically split and executed across appropriate shardsDBSIZE, logical AND forSCRIPT EXISTS, etc.)ClusterCommandArgumentsclass - hash slot tracking is now unified inCommandArgumentsBreaking Changes
CommandExecutorinterface: RemovedbroadcastCommand()default method - implementations should useClusterCommandExecutor.broadcastCommand(commandObject, primaryOnly)directlyClusterCommandArguments: Deleted - useCommandArgumentswithgetKeyHashSlots()insteadJedisBroadcastAndRoundRobinConfig: Removed (functionality integrated into executor)Fixes: #990