MOD-15749 Short-form CLUSTERSET: reject when the cluster API has no usable node endpoints - #101
Closed
gabsow wants to merge 1 commit into
Closed
Conversation
…sable node endpoints The short form derives each shard's ip:port from RedisModule_GetClusterNodeInfo. On Redis builds where the module cluster topology is not fully populated -- e.g. Redis Enterprise without the node-port backport, where getNodeDefaultClientPort() returns 0 (RED-202230) -- that API yields no valid endpoint, so we would build an empty/port-0 topology and still reply +OK. The caller (DMC) then believes the cluster is configured and never falls back to the long form, leaving cross-shard commands silently broken (and risking an assert crash on the slot-ranges path). Mirror RediSearch's defensive handling: - skip nodes whose endpoint is missing (rc != OK, port <= 0, or empty ip); - replace RedisModule_Assert(slots != NULL) with a soft skip (no field crash); - if no valid master shards remain, reply with an error so the caller can fall back to the long-form CLUSTERSET (which carries the endpoints explicitly). This does not make the short form work in RE (that needs the core fix RED-202230); it makes TimeSeries fail safely there instead of silently misconfiguring.
Contributor
Author
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.
Problem
The short form of
CLUSTERSETderives each shard'sip:portfromRedisModule_GetClusterNodeInfo. On Redis builds where the module cluster topology isn't fully populated — notably Redis Enterprise without the node-port backport, wheregetNodeDefaultClientPort()returns0(RED-202230) — that API yields no usable endpoint (port0/ empty ip), and today's code:rc != REDISMODULE_OK), so it builds nodes pointing at port 0 — or skips all nodes and builds an empty topology;return REDISMODULE_OK, so the caller (DMC) gets+OK, believes the cluster is configured, and never falls back to the long form → cross-shard commands silently break;RedisModule_Assert(slots != NULL)can crash the shard outright.RediSearch hit exactly this in RE and fails loudly (returns an "invalid topology" error). LibMR currently fails silently — worse.
Fix
Mirror RediSearch's defensive handling in
SetClusterDataShortForm:rc != OK || port <= 0 || ip[0] == '\0'); zero-init the locals so the check is reliable.RedisModule_Assert(slots != NULL)with a soft skip (no field crash).MR_ClusterFree()and return an error so the caller can fall back to the long-form CLUSTERSET (which carries endpoints explicitly).This does not make the short form work in RE (that needs the core fix, RED-202230). It makes the module fail safely there — return an error instead of silently installing a broken topology — which is a prerequisite for DMC's try-then-fallback.
Testing
cluster.ccompiles andlibmr.alinks clean. The new paths require the RE port bug to exercise (no OSS redis returns port 0), so they're covered by code review here + the enterprise beta; the existingtestShortFormClusterSetWithoutSlotRangesApi(no-API path) and the RedisTimeSeries oss-cluster flow test (success path) are unaffected.🤖 Generated with Claude Code
Note
Medium Risk
Changes cluster topology installation for a critical cross-shard path; behavior is more defensive but alters success/failure when the cluster API is incomplete (e.g. enterprise without port backport).
Overview
Short-form
CLUSTERSETinSetClusterDataShortFormno longer treats a partially empty Redis module cluster API as success.Nodes are skipped when
RedisModule_GetClusterNodeInfofails or returns an empty IP or non-positive port (e.g. Redis Enterprise without the node-port backport, RED-202230).RedisModule_Assert(slots != NULL)is replaced with a warning and skip when slot ranges are missing.If no valid master shards remain after that pass, the half-built topology is torn down via
MR_ClusterFree()and the function returnsREDISMODULE_ERRso callers like DMC can fall back to long-formCLUSTERSETinstead of replying OK with port-0 or empty topology.Reviewed by Cursor Bugbot for commit 594375d. Bugbot is set up for automated code reviews on this repo. Configure here.