Skip to content

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

Merged
GuyAv46 merged 1 commit into
8.8from
backport-9779-to-8.8
May 25, 2026
Merged

GuyAv46 merged 1 commit into
8.8from
backport-9779-to-8.8

Conversation

@redisearch-backport-pull-request

@redisearch-backport-pull-request redisearch-backport-pull-request Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #9779 to 8.8.

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 built and which nodes/slots are included; wrong filtering or API ownership could mis-route queries, but long-form path and feature gating limit blast radius.

Overview
Adds a 3-argument search.CLUSTERSET AUTH <password> path so the coordinator can refresh cluster topology from the Redis Module cluster APIs instead of the long MYID / RANGES / SHARD form.

MRClusterTopology_FromAPI walks cluster nodes, keeps masters with slots, applies the password to each shard endpoint, clones slot ranges (freeing module-owned arrays explicitly), and sets my_shard_idx when the local node is a slotted master—replica or slot-less local nodes stay at UINT32_MAX like the long parser.

RedisEnterprise_ParseTopology routes to the short form only when argc == 3 and RedisModule_GetClusterNodeSlotRanges is available; otherwise behavior is unchanged. redismodule.h gains the slot-ranges API stub until upstream sync; SetClusterCommand logging on parse failure is simplified.

Tests add a configurable cluster mock and coverage for FromAPI filtering/errors and short-form dispatch boundaries.

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

…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)
@jit-ci

jit-ci Bot commented May 25, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@sonarqubecloud

Copy link
Copy Markdown

@redisearch-backport-pull-request
redisearch-backport-pull-request Bot added this pull request to the merge queue May 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 25, 2026
@GuyAv46
GuyAv46 added this pull request to the merge queue May 25, 2026
Merged via the queue into 8.8 with commit c1d66f8 May 25, 2026
32 checks passed
@GuyAv46
GuyAv46 deleted the backport-9779-to-8.8 branch May 25, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant