Skip to content

Conversation

@galcohen-redislabs
Copy link
Collaborator

@galcohen-redislabs galcohen-redislabs commented Oct 8, 2025

Note

Update slot-ownership logic to use RedisModule_ClusterCanAccessKeysInSlot on OSS and extend redismodule.h with new cluster migration events/structs, keyspace flags, config iterator/get/set, and related APIs wired into init.

  • Cluster:
    • Update MR_ClusterIsMySlot to use RedisModule_ClusterCanAccessKeysInSlot on OSS; enterprise uses RedisModule_ShardingGetSlotRange; fallback to cached clusterCtx slot range.
  • Module API (redismodule.h):
    • Keyspace notifications: add REDISMODULE_NOTIFY_OVERWRITTEN, REDISMODULE_NOTIFY_TYPE_CHANGED, REDISMODULE_NOTIFY_KEY_TRIMMED; bump _REDISMODULE_NOTIFY_NEXT.
    • Events: add REDISMODULE_EVENT_CLUSTER_SLOT_MIGRATION and ..._TRIM with subevents; expose RedisModuleEvent_ClusterSlotMigration*.
    • Data structs: add RedisModuleSlotRange{,Array}, RedisModuleClusterSlotMigrationInfo, RedisModuleClusterSlotMigrationTrimInfo.
    • Config API: introduce RedisModuleConfigType, RedisModuleConfigIterator and config get/set helpers.
    • Cluster APIs: add RedisModule_ClusterCanAccessKeysInSlot, ...ClusterPropagateForSlotMigration, ...ClusterGetLocalSlotRanges, ...ClusterFreeSlotRanges.
    • Other: add RedisModule_UnsubscribeFromKeyspaceEvents.
    • Wire all new APIs via REDISMODULE_GET_API.

Written by Cursor Bugbot for commit 93b1ace. This will update automatically on new commits. Configure here.

src/cluster.c Outdated

int MR_ClusterIsMySlot(size_t slot) {
if (RedisModule_ShardingGetSlotRange) {
if (RedisModule_ClusterCanAccessKeysInSlot != NULL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, I wasn't expecting this part in libmr. Thank you for catching it.

Even if we have RedisModule_ClusterCanAccessKeysInSlot(), we may need to use RedisModule_ShardingGetSlotRange() if this is non-asm RE build with Redis 8.4+ :(

Libmr needs to know what kind of clustering is this. I'm not familiar with libmr but I'll try to check it later.
In summary,

  • For OSS, we should call RedisModule_ClusterCanAccessKeysInSlot() if it exists. Otherwise, fallback to clusterCtx.minSlot and clusterCtx.maxSlot. (I'm not sure about this yet, perhaps you may have an idea)
  • For RE, if this is not OSS clustering, we should call RedisModule_ShardingGetSlotRange(), otherwise, we'll call RedisModule_ClusterCanAccessKeysInSlot(). I'm not sure how libmr can detect this yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now the ask is to adjust to oss cluster only. The adjustments needed for RE with oss-cluster bdbs will come next.
So I'll rely on clusterCtx.isOss for now and will add whatever code is needed for RE ASMs under another ticket.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, thanks. Tomorrow, I'll consult others to confirm how we can handle this, maybe we can do something like:

    if (RedisModule_ShardingGetSlotRange) {
        int first_slot, last_slot;
        RedisModule_ShardingGetSlotRange(&first_slot, &last_slot);
        if (first_slot != -1 && last_slot != -1) {  
           /* RE resharding is enabled */
           return first_slot <= slot && last_slot >= slot;
        }
        /* RE sharding is not enabled, try other methods.. */
     }
     
     if (RedisModule_ClusterCanAccessKeysInSlot != NULL)
        return RedisModule_ClusterCanAccessKeysInSlot(slot);
        
    // Fallback.
    return clusterCtx.minSlot <= slot && clusterCtx.maxSlot >= slot;

tezc
tezc previously approved these changes Oct 14, 2025
Copy link
Collaborator

@tezc tezc left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks.

Note: For RE builds, we need adjustment in MR_ClusterIsMySlot() to detect if RE resharding or OSS clustering is used.

@galcohen-redislabs
Copy link
Collaborator Author

LGTM! Thanks.

Note: For RE builds, we need adjustment in MR_ClusterIsMySlot() to detect if RE resharding or OSS clustering is used.

Indeed, but that would be under https://redislabs.atlassian.net/browse/MOD-11623

tezc
tezc previously approved these changes Oct 16, 2025
@CLAassistant
Copy link

CLAassistant commented Oct 22, 2025

CLA assistant check
All committers have signed the CLA.

@gabsow gabsow force-pushed the gal-11322-asm-support branch 19 times, most recently from f308f66 to 0859b00 Compare October 22, 2025 18:55
@gabsow gabsow force-pushed the gal-11322-asm-support branch 2 times, most recently from 72d98ac to 93b1ace Compare October 23, 2025 05:50
@gabsow gabsow merged commit c48654b into master Oct 23, 2025
2 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants