MOD-15749 Short-form CLUSTERSET: reject on non-cluster (standalone) shard (RED-207632) - #102
Closed
gabsow wants to merge 1 commit into
Closed
Conversation
…hard (RED-207632) SetClusterDataShortForm builds the topology from the cluster API. On a standalone shard RedisModule_GetMyClusterID() returns NULL, and SetMyId then runs memcpy(myId, NULL, REDISMODULE_NODE_ID_LEN) -> SIGSEGV in the LibMR event-loop thread (crash seen in test_asm_happyflow_flag_toggle, RED-207632). The long form is unaffected because it takes myId from the command arguments. Guard the short-form path with the same REDISMODULE_CTX_FLAGS_CLUSTER check MR_RefreshClusterData already uses: on a non-cluster shard, log and return REDISMODULE_ERR instead of crashing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes a NULL-pointer SIGSEGV in the LibMR event-loop thread (
timeseries-el) when a short-formCLUSTERSETreaches a non-cluster (standalone) shard — crash reported in RED-207632 (test_asm_happyflow_flag_toggle, ASM nightly).Root cause
SetClusterDataShortFormbuilds the topology entirely from the cluster API. It callsInitClusterData→SetMyId, which does:On a standalone shard
RedisModule_GetMyClusterID()returnsNULL, so this ismemcpy(dst, NULL, REDISMODULE_NODE_ID_LEN). It runs in the event-loop thread becauseMR_ClusterSetschedulesMR_ClusterSetFromCommandviaMR_EventLoopAddTask. This matches the crash exactly (faulting threadtimeseries-el,RSI=0,RDX=0x28= 40 =REDISMODULE_NODE_ID_LEN).The long form is unaffected — it takes
myIdfrom the command arguments (argv[CLUSTERSET_MYID_LONG_FORM_INDEX]), never fromGetMyClusterID().Fix
Guard the short-form path with the same
REDISMODULE_CTX_FLAGS_CLUSTERcheckMR_RefreshClusterDataalready uses: if the shard is not in cluster mode, log a warning and returnREDISMODULE_ERR(the same failure contract as the sibling "slot-ranges API missing" rejection right above it) instead of crashing. The shard stays unconfigured until cluster mode is enabled or a long-formCLUSTERSET/REFRESHCLUSTERarrives.Verification
make -C src/compiles cleanly with the change.Note
Low Risk
Small defensive guard on an error path already used elsewhere; long-form and clustered short-form behavior unchanged.
Overview
Fixes a SIGSEGV in the LibMR event-loop thread when short-form
CLUSTERSETis handled on a standalone (non-cluster) Redis instance.Short-form topology setup calls
SetMyId, which usesRedisModule_GetMyClusterID(); that API returns NULL without cluster mode, leading to a NULLmemcpyand crash.SetClusterDataShortFormnow checksREDISMODULE_CTX_FLAGS_CLUSTER(same pattern asMR_RefreshClusterData): if cluster mode is off, it logs a warning and returnsREDISMODULE_ERR, leaving the shard unconfigured until cluster mode is on or a long-formCLUSTERSET/REFRESHCLUSTERsucceeds.Long-form
CLUSTERSETand short-form on clustered shards are unchanged.Reviewed by Cursor Bugbot for commit 3020b2e. Bugbot is set up for automated code reviews on this repo. Configure here.