Skip to content

[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
topic/ggivo/request-response-policy-support-reject-multinode-commands-in-pipeline
Mar 18, 2026
Merged

[req/resp] Reject commands with ALL_NODES,ALL_SHARDS,MULTI_SHARD request policy in Cluster Pipeline#4466
ggivo merged 4 commits intoim/request-response-policy-supportfrom
topic/ggivo/request-response-policy-support-reject-multinode-commands-in-pipeline

Conversation

@ggivo
Copy link
Copy Markdown
Collaborator

@ggivo ggivo commented Mar 18, 2026

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 shards
  • MGET with keys in different slots - requires execution on multiple shards
  • SCRIPT LOAD - requires execution on all nodes

For multi-node commands, use the non-pipelined mode of RedisCluster instead.


Note

Medium Risk
Changes cluster pipeline behavior by throwing UnsupportedOperationException for 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. MultiNodePipelineBase validates each appended command against CommandFlagsRegistry request policies and rejects ALL_SHARDS/MULTI_SHARD/ALL_NODES/SPECIAL commands unless all keys map to a single hash slot.

JedisCluster and RedisClusterClient now pass a CommandFlagsRegistry into ClusterPipeline (builder paths use the configured registry), and ClusterPipeline adds documentation describing the new limitation. New integration tests cover rejected vs allowed cases (e.g., KEYS, cross-slot MGET, single-slot EXISTS, SCRIPT EXISTS with sample key). Separately, CI workflow triggers are expanded to include topic/** branches.

Written by Cursor Bugbot for commit d9e4b85. This will update automatically on new commits. Configure here.

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Mar 18, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 18, 2026

Test Results

   308 files  ± 0     308 suites  ±0   12m 11s ⏱️ +27s
11 127 tests +12  11 071 ✅ +417  56 💤  - 405  0 ❌ ±0 
 5 842 runs  +18   5 833 ✅ +163   9 💤  - 145  0 ❌ ±0 

Results for commit d9e4b85. ± Comparison against base commit a05f1bc.

♻️ This comment has been updated with latest results.

@ggivo ggivo marked this pull request as ready for review March 18, 2026 09:36
@ggivo ggivo requested a review from uglide March 18, 2026 09:36
@ggivo ggivo merged commit 23f7def into im/request-response-policy-support Mar 18, 2026
12 checks passed
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]>
@ggivo ggivo deleted the topic/ggivo/request-response-policy-support-reject-multinode-commands-in-pipeline branch March 24, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants