Skip to content

Align Search APIs and behaviour with Redis 8.0+ #4173

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

uglide
Copy link
Contributor

@uglide uglide commented Jun 6, 2025

  • Introduce executeKeylessCommand
  • Implement round-robin execution in ClusterCommandExecutor
  • Update search commands according to the latest request/response policies
  • Remove JedisBroadcastAndRoundRobinConfig
  • Introduce AggregateIterator for proper Cluster support
  • Deprecate APIs that rely on legacy RediSeach behaviour

- Introduce executeKeylessCommand
- Implement round-robin execution in ClusterCommandExecutor
- Update search commands according to the latest request/response policies
- Remove JedisBroadcastAndRoundRobinConfig
- Introduce AggregateIterator for proper Cluster support
- Deprecate APIs that rely on legacy RediSeach behaviour
@uglide uglide force-pushed the imalinovskyi_keyless_command_execution branch from 85ff14f to f85344a Compare June 12, 2025 12:23
@uglide uglide changed the title Introduce keyless-commands execution @uglide Align Search APIs and behaviour with Redis 8.0+ Jun 12, 2025
@uglide uglide changed the title @uglide Align Search APIs and behaviour with Redis 8.0+ Align Search APIs and behaviour with Redis 8.0+ Jun 12, 2025
Copy link

github-actions bot commented Jun 13, 2025

Test Results

  249 files  + 1    249 suites  +1   9m 26s ⏱️ -2s
4 614 tests +18  4 610 ✅ +61  4 💤  - 43  0 ❌ ±0 
2 483 runs  + 9  2 483 ✅ + 9  0 💤 ± 0  0 ❌ ±0 

Results for commit 270a625. ± Comparison against base commit 60c356b.

♻️ This comment has been updated with latest results.

@uglide uglide requested review from Copilot and ggivo June 13, 2025 09:36
Copy link
Contributor

@Copilot Copilot AI left a 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 aligns various Redis search APIs with Redis 8.0+ policies by introducing a new keyless command execution method, implementing round‑robin distribution for keyless commands in cluster mode, and replacing legacy search iteration APIs with a more robust AggregateIterator. Key changes include the introduction of executeKeylessCommand, removal of JedisBroadcastAndRoundRobinConfig, and the implementation of round‑robin scheduling in ClusterCommandExecutor.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/test/java/redis/clients/jedis/modules/search/AggregateIteratorTest.java New tests for AggregateIterator covering basic use, cursor removal and error cases
src/main/java/redis/clients/jedis/search/aggr/AggregationBuilder.java Adds cursorCount tracking when using cursor-based aggregation
src/main/java/redis/clients/jedis/search/aggr/AggregateIterator.java Implements a new iterator for aggregation results with proper cursor management
src/main/java/redis/clients/jedis/executors/ClusterCommandExecutor.java Introduces round‑robin distribution for keyless command execution
src/main/java/redis/clients/jedis/UnifiedJedis.java Updates search commands to use the new executeKeylessCommand method and deprecates legacy APIs
src/main/java/redis/clients/jedis/CommandObjects.java Adjusts round‑robin command routing logic and removes unused configuration
Comments suppressed due to low confidence (1)

src/main/java/redis/clients/jedis/CommandObjects.java:3443

  • [nitpick] Add a comment explaining why certain SearchCommands (SUGGET, SUGADD, SUGLEN, SUGDEL, CURSOR) are excluded from round-robin routing to aid future maintainers.
private boolean isRoundRobinSearchCommand(SearchCommand sc) {

Comment on lines +210 to +216
// Convert connection map to list for round-robin access
List<Map.Entry<String, ConnectionPool>> nodeList = new ArrayList<>(connectionMap.entrySet());

// Select node using round-robin distribution for true unified distribution
// Use modulo directly on the node list size to create a circular counter
int roundRobinIndex = roundRobinCounter.getAndUpdate(current -> (current + 1) % nodeList.size());
Map.Entry<String, ConnectionPool> selectedEntry = nodeList.get(roundRobinIndex);
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider caching the node list or optimizing the round-robin selection process if the connection map does not change frequently, to reduce repetitive list creation and improve efficiency.

Suggested change
// Convert connection map to list for round-robin access
List<Map.Entry<String, ConnectionPool>> nodeList = new ArrayList<>(connectionMap.entrySet());
// Select node using round-robin distribution for true unified distribution
// Use modulo directly on the node list size to create a circular counter
int roundRobinIndex = roundRobinCounter.getAndUpdate(current -> (current + 1) % nodeList.size());
Map.Entry<String, ConnectionPool> selectedEntry = nodeList.get(roundRobinIndex);
// Check if the connection map size has changed
if (cachedNodeList == null || cachedConnectionMapSize != connectionMap.size()) {
synchronized (this) {
if (cachedNodeList == null || cachedConnectionMapSize != connectionMap.size()) {
cachedNodeList = new ArrayList<>(connectionMap.entrySet());
cachedConnectionMapSize = connectionMap.size();
}
}
}
// Select node using round-robin distribution for true unified distribution
// Use modulo directly on the node list size to create a circular counter
int roundRobinIndex = roundRobinCounter.getAndUpdate(current -> (current + 1) % cachedNodeList.size());
Map.Entry<String, ConnectionPool> selectedEntry = cachedNodeList.get(roundRobinIndex);

Copilot uses AI. Check for mistakes.

@ggivo ggivo added the breakingchange Pull request that has breaking changes. Must include the breaking behavior in release notes. label Jun 16, 2025
@ggivo ggivo added this to the 7.0.0 milestone Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakingchange Pull request that has breaking changes. Must include the breaking behavior in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants