Skip to content

[MOD-15867] coord: search.CLUSTERSET AUTH <pw> short-form using module API - #9779

Merged
GuyAv46 merged 13 commits into
masterfrom
guyav-parse_topology_with_API
May 25, 2026
Merged

GuyAv46 merged 13 commits into
masterfrom
guyav-parse_topology_with_API

Conversation

@GuyAv46

@GuyAv46 GuyAv46 commented May 22, 2026 •

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

  1. Current: search.CLUSTERSET accepts only the long form (MYID … RANGES n SHARD … SLOTRANGE … ADDR … MASTER …), which forces the orchestrator to enumerate every shard's slot range, host, and port.
  2. Change: Add a short form, search.CLUSTERSET AUTH <password>, that builds the topology directly from the Redis Module cluster API. The new MRClusterTopology_FromAPI walks RedisModule_GetClusterNodesList / GetClusterNodeInfo / GetClusterNodeSlotRanges, keeps master nodes that own slots, sets the password on every endpoint, and marks the local node (REDISMODULE_NODE_MYSELF) as my_shard_idx. RedisEnterprise_ParseTopology dispatches to the short form when argc == 3 && RedisModule_GetClusterNodeSlotRanges.
  3. Outcome: When the host supplies RedisModule_GetClusterNodeSlotRanges (upstream Redis PR Add RM_GetClusterNodeSlotRanges module API redis/redis#14953, planned for OSS Redis 8.10 and backported to Enterprise 8.4), the orchestrator can send a 3-argument search.CLUSTERSET AUTH <pw> and the module computes the topology itself. Long-form behavior is unchanged when the gate isn't taken.

Which additional issues this PR fixes

  1. MOD-15867

Main objects this PR modified

  1. MRClusterTopology_FromAPI (new) — src/coord/rmr/cluster_topology.c. Manages module-owned slot range arrays explicitly via RedisModule_ClusterFreeSlotRanges (per PR review preference to avoid RedisModule_AutoMemory).
  2. parse_topology_short_form (new) and RedisEnterprise_ParseTopology dispatch — src/coord/rmr/redise.c
  3. RedisModule_GetClusterNodeSlotRanges declaration added to src/redismodule.h at the same position upstream places it (next to GetClusterNodeInfo / GetClusterNodesList); to be removed when the file is re-synced from upstream after #14953 lands.
  4. Test mocks for the cluster-node APIs (GetClusterNodesList, GetClusterNodeInfo, GetMyClusterID, GetClusterSize, GetClusterNodeSlotRanges, FreeClusterNodesList) — tests/cpptests/redismock/
  5. New tests: 13 unit tests for MRClusterTopology_FromAPI (test_cpp_cluster_topology.cpp) and 5 dispatch/short-form tests appended to test_cpp_clusterset.cpp. Verified end-to-end against a 3-node cluster built from #14953.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

The API change is the new search.CLUSTERSET AUTH <password> short form. The long form is untouched.

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

search.CLUSTERSET now accepts a 3-argument short form, search.CLUSTERSET AUTH <password>, on hosts that expose RedisModule_GetClusterNodeSlotRanges (OSS Redis 8.10+ / Enterprise 8.4+ backport). The orchestrator no longer needs to spell out shards and slot ranges — the module fetches them from the cluster.

Follow-up

  • Once the vendored src/redismodule.h is re-synced from upstream after #14953 lands, drop the manual declaration of RedisModule_GetClusterNodeSlotRanges added here (it should already match upstream's position, so this is a straight diff).
  • Once the API is universally available, remove the && RedisModule_GetClusterNodeSlotRanges half of the dispatch gate in RedisEnterprise_ParseTopology, and use it for OSS as well instead of calling CLUSTER SHARDS.

🤖 Generated with Claude Code


Note

Medium Risk
Changes how cluster topology is discovered and applied for coordinators; wrong filtering or slot cloning could mis-route queries, but long-form remains and behavior is gated on the new API pointer.

Overview
Adds a 3-argument search.CLUSTERSET AUTH <password> path when the host exposes RedisModule_GetClusterNodeSlotRanges. MRClusterTopology_FromAPI builds the coordinator topology from the module cluster APIs (node list, node info, per-node slot ranges): masters with slots only, optional password on every endpoint, my_shard_idx when the local node is a slotted master (replica/slot-less local node stays UINT32_MAX, same as long-form). RedisEnterprise_ParseTopology routes argc == 3 to that path; long-form parsing is unchanged otherwise.

Declares RedisModule_GetClusterNodeSlotRanges in vendored redismodule.h until upstream sync. SetClusterCommand drops verbose invalid-arg / per-shard range logging. redismock gains a configurable cluster mock and tests for FromAPI and short-form dispatch.

Reviewed by Cursor Bugbot for commit 35fc497. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci

jit-ci Bot commented May 22, 2026 •

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@GuyAv46 GuyAv46 changed the title [MOD-xxxxx] coord: FT.CLUSTERSET AUTH <pw> short-form using module API [MOD-xxxxx] coord: search.CLUSTERSET AUTH <pw> short-form using module API May 22, 2026
GuyAv46 and others added 4 commits May 22, 2026 11:28
- cluster_topology.c: take RedisModule_ClusterGetSlotRangesByNodeId result
  as pointer-to-const (S5350).
- redismock.cpp: switch the cluster-mock locks from std::lock_guard<std::mutex>
  to std::scoped_lock (S5997, S6012); use const references in iteration loops
  (S5350); mark unused ctx/master_id parameters as unnamed (S1172).
- test_cpp_cluster_topology.cpp: pass addNode's slots by const reference
  (S1238); use nullptr instead of NULL (S4962).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The "?" sentinel is a CLUSTER SHARDS reply convention for an unknown
endpoint; the RedisModule_GetClusterNodeInfo API doesn't return it. Drop
the check and the NODE_D fixture that exercised it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Rename RedisModule_ClusterGetSlotRangesByNodeId →
RedisModule_GetClusterNodeSlotRanges to match the symbol name in the
upstream Redis PR that adds this API
(redis/redis#14953). Move the redismodule.h
declaration and REDISMODULE_GET_API call to the same position upstream
places them (next to GetClusterNodeInfo) so the file stays close to a
straight diff against upstream once the PR lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@GuyAv46 GuyAv46 changed the title [MOD-xxxxx] coord: search.CLUSTERSET AUTH <pw> short-form using module API [MOD-15867] coord: search.CLUSTERSET AUTH <pw> short-form using module API May 24, 2026
@GuyAv46
GuyAv46 requested a review from alonre24 May 24, 2026 09:32
@GuyAv46
GuyAv46 marked this pull request as ready for review May 24, 2026 09:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60d75287d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/coord/rmr/cluster_topology.c Resolved
@codecov

codecov Bot commented May 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.72131% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.69%. Comparing base (dfa36fc) to head (35fc497).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
src/coord/rmr/redise.c 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9779      +/-   ##
==========================================
+ Coverage   81.35%   81.69%   +0.34%     
==========================================
  Files         511      508       -3     
  Lines       69233    68841     -392     
  Branches    25689    25220     -469     
==========================================
- Hits        56324    56241      -83     
+ Misses      12665    12359     -306     
+ Partials      244      241       -3     
Flag Coverage Δ
flow 84.52% <4.91%> (-0.10%) ⬇️
unit 49.84% <93.44%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GuyAv46
GuyAv46 requested a review from Itzikvaknin May 24, 2026 10:15
Comment thread src/coord/rmr/cluster_topology.c Resolved
Comment thread src/coord/rmr/redise.c Resolved
@GuyAv46
GuyAv46 requested a review from Itzikvaknin May 24, 2026 13:34
Comment thread src/coord/rmr/cluster_topology.c Resolved
Comment thread src/coord/rmr/cluster_topology.c Resolved
Comment thread src/coord/rmr/redise.c Resolved
Comment thread src/coord/rmr/cluster_topology.c Resolved
Comment thread src/coord/rmr/cluster_topology.c Resolved
Comment thread src/coord/rmr/cluster_topology.c Resolved
@GuyAv46
GuyAv46 requested review from Itzikvaknin and alonre24 May 25, 2026 06:03
Comment thread src/coord/rmr/redise.c Resolved
Itzikvaknin
Itzikvaknin previously approved these changes May 25, 2026

@Itzikvaknin Itzikvaknin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice work

@GuyAv46
GuyAv46 added this pull request to the merge queue May 25, 2026
@GuyAv46
GuyAv46 removed this pull request from the merge queue due to a manual request May 25, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1231c7d. Configure here.

Comment thread src/coord/rmr/cluster_topology.c Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1231c7d668

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/coord/rmr/redise.c Resolved
@sonarqubecloud

Copy link
Copy Markdown

@GuyAv46
GuyAv46 requested a review from Itzikvaknin May 25, 2026 08:35
@GuyAv46
GuyAv46 added this pull request to the merge queue May 25, 2026
Merged via the queue into master with commit 9a6b9b1 May 25, 2026
50 checks passed
@GuyAv46
GuyAv46 deleted the guyav-parse_topology_with_API branch May 25, 2026 15:43
@redisearch-backport-pull-request

Copy link
Copy Markdown
Contributor

Backport failed for 8.4, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.4
git worktree add -d .worktree/backport-9779-to-8.4 origin/8.4
cd .worktree/backport-9779-to-8.4
git switch --create backport-9779-to-8.4
git cherry-pick -x 9a6b9b1ea8f52e2f752177c05e06863c4d1e32c0

@redisearch-backport-pull-request

Copy link
Copy Markdown
Contributor

Backport failed for 8.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.6
git worktree add -d .worktree/backport-9779-to-8.6 origin/8.6
cd .worktree/backport-9779-to-8.6
git switch --create backport-9779-to-8.6
git cherry-pick -x 9a6b9b1ea8f52e2f752177c05e06863c4d1e32c0

@redisearch-backport-pull-request

Copy link
Copy Markdown
Contributor

Successfully created backport PR for 8.6-rse:

@redisearch-backport-pull-request

Copy link
Copy Markdown
Contributor

Successfully created backport PR for 8.8:

GuyAv46 added a commit that referenced this pull request May 26, 2026
…ule API (#9779)

* Implement MRClusterTopology_FromAPI function to retrieve cluster topology from module API

* Add parse_topology_short_form function to handle short form topology parsing

* Add tests and new required mock API

* Refactor RMCK_GetClusterNodesList and RMCK_GetClusterNodeInfo to use std::string::copy for safer string handling

* Address SonarCloud lints in new short-form code

- cluster_topology.c: take RedisModule_ClusterGetSlotRangesByNodeId result
  as pointer-to-const (S5350).
- redismock.cpp: switch the cluster-mock locks from std::lock_guard<std::mutex>
  to std::scoped_lock (S5997, S6012); use const references in iteration loops
  (S5350); mark unused ctx/master_id parameters as unnamed (S1172).
- test_cpp_cluster_topology.cpp: pass addNode's slots by const reference
  (S1238); use nullptr instead of NULL (S4962).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Drop unreachable ip[0] == '?' check in MRClusterTopology_FromAPI

The "?" sentinel is a CLUSTER SHARDS reply convention for an unknown
endpoint; the RedisModule_GetClusterNodeInfo API doesn't return it. Drop
the check and the NODE_D fixture that exercised it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Align cluster slot-ranges API name with upstream Redis PR #14953

Rename RedisModule_ClusterGetSlotRangesByNodeId →
RedisModule_GetClusterNodeSlotRanges to match the symbol name in the
upstream Redis PR that adds this API
(redis/redis#14953). Move the redismodule.h
declaration and REDISMODULE_GET_API call to the same position upstream
places them (next to GetClusterNodeInfo) so the file stays close to a
straight diff against upstream once the PR lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Manage cluster-API allocations explicitly instead of via auto-memory

* address review comments

* move validity checks to logged branch

* RedisModule_GetClusterNodeSlotRanges never returns NULL

* add defensive check back

* fix security concern

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
(cherry picked from commit 9a6b9b1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants