[req/resp] Reject commands with ALL_NODES,ALL_SHARDS,MULTI_SHARD request policy in Cluster Pipeline#4466
Merged
ggivo merged 4 commits intoim/request-response-policy-supportfrom Mar 18, 2026
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
uglide
approved these changes
Mar 18, 2026
ggivo
added a commit
that referenced
this pull request
Mar 20, 2026
* Introduce keyless command concept * Introduce request/response policies to CommandFlagsRegistry and StaticCommandFlagsRegistry * Update CommandFlagsRegistryGenerator to support request/response policies * Drop broadcastCommand and executeKeylessCommand from the CommandExecutor interface The logic on how command should be routed should be decided in CommandExecutor based on command request/response policy and client configuration * Add isKeyless() to CommandArguments * Add support for MULTI_SHARD commands * Get rid of ClusterCommandArguments * Fix ClusterReplyAggregator * Expose addHashSlotKey method for special cases like KEYS command * Allow manual overrides in CommandFlagsRegistryGenerator * Fix tests * Add missing exception class * Clean up after dropping FT.Aggregate iterator * Fix formatting * Add missing ClusterAggregationException * Fix unit tests * Fix bugs with hash slots * Add support for arrays in AND&OR aggregations * Add support for DBSIZE and add more tests * Optimize hash slot calculation and get rid of processKey() methods * Deprecate sendCommand() and sendBlockingCommand() as unsafe in cluster mode * Update tests to reflect the changes * Resolve merge problems * Address feedback for CommandFlagsRegistryGenerator - Remove KEYS override in generator - Remove validations for KEYS pattern in Cluster - Implement proper Set/List/Map aggregation infra for default response policy - Add integration test for CLUSTER SLOT-STATS * Reformat * Add missing import to CommandFlagsRegistryGenerator * Make executeKeylessCommand private * Extract sendCommand methods deprecation * Improve CommandFlagsRegistryGenerator - Handle properly subcommands for HOTKEYS, FT.CURSOR, FT.CONFIG - Raise an exception if unknown parent command is detected * Preserve the initial order when executing multi-shard commands - Adjust the groupArgumentsByKeyValueHashSlotImpl to fix the ordering bug - Document how performance of MGET can be improved * Add Connection resolvers Co-authored-by: ggivo <[email protected]> * Refactor broadcastCommand and executeMultiShardCommand to use common MultiNodeResultAggregator * Reformat * Update tests * Reformat * Fix bug in CommandArguments * Fix bug with SingleConnectionResolver * Fix bug with roundRobinResolver * Take into account keyPreProcessor in groupArgumentsByKeyValueHashSlotImpl * Replace outdated test in ClusterBinaryValuesCommandsTest * Throw redirection exceptions immediately when followRedirections is false * Add support for JedisByteHashMap and JedisByteMap in default aggregation * Reformat * Mutate exising collection in aggregateDefault() * Address review suggestions and clean up code * Make ClusterReplyAggregator pp * Fix tests * Fix SinceRedisVersion for clusterSlotStatsAggregation test * Fix aggregation for WAITAOF command and improve exception message * fix ClientAuthRedisClusterClientIT.java:[43,13] cannot find symbol * getKeys now returns unmodifiable list * CommnadArguments.addHashSlotKey - package private & typesafe * [req/resp] Reject commands with ALL_NODES,ALL_SHARDS,MULTI_SHARD request policy in Cluster Pipeline (#4466) * reject commands with ALL_NODES,ALL_SHARDS,MULTI_SHARD request policy in cluster pipeline * run test on topic branches * api docs fix * If the command has keys that route to a single slot, allow it * [req/resp] Fix aggregating unmodifiable collection failiure (#4465) * refactore: fix empty Map/Set should return emtpy not null refactore: statefull aggregators fix tests refactore: statefull aggregators * refactore: statefull aggregators add test for ReplyAggregatorTest * refactore: MultiNodeResultAggregator to aggregator package and mark with @internal * refactore: reuse LogicalAnd & LogicalOr aggregators * format * remove ClusterReplyAggregator replaced by aggregators/ClusterReplyAggregator * triger test * address review comments and fix Set[byte[]] aggregation * address review comments - test puts entries into wrong map variable - Byte array set dedup skipped when first part empty * address review comments - JedisByteHashMapAggregator.add() and JedisByteMapAggregator.add() skip empty maps * format * parameterize map test * remove unused import * override INFO & FUNCITON_STATS request policy for cluster to DEFAULT * formating --------- Co-authored-by: ggivo <[email protected]>
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.
ClusterPipeline allows batching multiple commands for efficient execution in a Redis Cluster environment. Commands are automatically routed to the appropriate cluster nodes based on key hash slots. Introducing req/resp policy support now allows command execution on multiple nodes and aggregating the responses, which is not supported in Cluster Pipeline executions.
This PR introduces validation/restriction on commands allowed to be used with ClusterPipeline.
Important Limitations
Single-node commands only: Only commands that can be routed to a single node are supported. Commands requiring execution on multiple nodes (ALL_SHARDS, MULTI_SHARD, ALL_NODES, or SPECIAL request policies) will throw
UnsupportedOperationException.Examples of unsupported commands:
KEYS- requires execution on all master shardsMGETwith keys in different slots - requires execution on multiple shardsSCRIPT LOAD- requires execution on all nodesFor multi-node commands, use the non-pipelined mode of
RedisClusterinstead.Note
Medium Risk
Changes cluster pipeline behavior by throwing
UnsupportedOperationExceptionfor commands requiring multi-node execution, which may break callers that previously (incorrectly) pipelined these commands. Logic relies on command flag metadata and key-slot detection, so edge-case routing/flagging mistakes could cause false rejections/allowances.Overview
Cluster pipelining now enforces single-node routing.
MultiNodePipelineBasevalidates each appended command againstCommandFlagsRegistryrequest policies and rejectsALL_SHARDS/MULTI_SHARD/ALL_NODES/SPECIALcommands unless all keys map to a single hash slot.JedisClusterandRedisClusterClientnow pass aCommandFlagsRegistryintoClusterPipeline(builder paths use the configured registry), andClusterPipelineadds documentation describing the new limitation. New integration tests cover rejected vs allowed cases (e.g.,KEYS, cross-slotMGET, single-slotEXISTS,SCRIPT EXISTSwith sample key). Separately, CI workflow triggers are expanded to includetopic/**branches.Written by Cursor Bugbot for commit d9e4b85. This will update automatically on new commits. Configure here.