Skip to content

Conversation

@StavRLevi
Copy link
Collaborator

This API complements module subscribe by enabling modules to unsubscribe from specific keyspace event notifications when they are no longer needed.
This helps reduce performance overhead and unnecessary callback invocations.

The function matches subscriptions based on event mask, callback pointer,
and module identity. If a matching subscription is found, it is removed.

Returns REDISMODULE_OK if a subscription was successfully removed, otherwise REDISMODULE_ERR.

@StavRLevi StavRLevi requested a review from ShooterIT June 9, 2025 12:06
@snyk-io
Copy link

snyk-io bot commented Jun 9, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@ShooterIT ShooterIT added the release-notes indication that this issue needs to be mentioned in the release notes label Jun 26, 2025
@sundb sundb added the state:needs-doc-pr requires a PR to redis-doc repository label Jul 8, 2025
Copy link
Collaborator

@sundb sundb left a comment

Choose a reason for hiding this comment

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

general LGTM

@sundb
Copy link
Collaborator

sundb commented Jul 8, 2025

@oranagra please take a brief look to see if the module API is reasonable.

* Parameters:
* - ctx: The RedisModuleCtx associated with the calling module.
* - types: The event mask representing the keyspace notification types to unsubscribe from.
* - callback: The callback function pointer that was originally registered for these events.
Copy link
Member

Choose a reason for hiding this comment

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

i'm no expert on that matter..
so currently, a module can register multiple callback to the same event, or even register the same callback multiple times, and it'll be called multiple times, is that right?

so in that sense, when we unregister, we must know exactly which registration they want to undo?
what happens if the exact same pair (callback and type) are registered multiple times? do we clear them all in one call?

LGTM.. just wanted to make sure i understand it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, a module can register the same callback multiple times ( with the same event mask), If the same (callback, mask) pair was registered multiple times, the current implementation removes all matching entries in one func call.. (we dont have a way to remove specific registration because we dont have identifier or something similar when we subscribe..)

@StavRLevi StavRLevi merged commit 8239671 into redis:unstable Jul 28, 2025
25 of 26 checks passed
@sundb sundb added this to Redis 8.2 Jul 28, 2025
@sundb sundb moved this from Todo to Done in Redis 8.2 Jul 28, 2025
@sundb sundb mentioned this pull request Aug 4, 2025
sundb added a commit that referenced this pull request Aug 4, 2025
This is the General Availability release of Redis Open Source 8.2.

### Major changes compared to 8.0

- Streams - new commands: `XDELEX` and `XACKDEL`; extension to `XADD`
and `XTRIM`
- Bitmap - `BITOP`: new operators: `DIFF`, `DIFF1`, `ANDOR`, and `ONE`
- Query Engine - new SVS-VAMANA vector index type which supports vector
compression
- More than 15 performance and resource utilization improvements
- New metrics: per-slot usage metrics, key size distributions for basic
data types, and more

### Binary distributions

- Alpine and Debian Docker images - https://hub.docker.com/_/redis
- Install using snap - see https://github.com/redis/redis-snap
- Install using brew - see https://github.com/redis/homebrew-redis
- Install using RPM - see https://github.com/redis/redis-rpm
- Install using Debian APT - see https://github.com/redis/redis-debian


### Operating systems we test Redis 8.2 on

- Ubuntu 22.04 (Jammy Jellyfish), 24.04 (Noble Numbat)
- Rocky Linux 8.10, 9.5
- AlmaLinux 8.10, 9.5
- Debian 12 (Bookworm)
- macOS 13 (Ventura), 14 (Sonoma), 15 (Sequoia)

### Security fixes (compared to 8.2-RC1)

- (CVE-2025-32023) Fix out-of-bounds write in `HyperLogLog` commands
- (CVE-2025-48367) Retry accepting other connections even if the
accepted connection reports an error

### New Features (compared to 8.2-RC1)

- #14141 Keyspace notifications - new event types:
  - `OVERWRITTEN` - the value of a key is completely overwritten
  - `TYPE_CHANGED` - key type change

### Bug fixes (compared to 8.2-RC1)

- #14162 Crash when using evport with I/O threads
- #14163 `EVAL` crash when error table is empty
- #14144 Vector sets - RDB format is not compatible with big endian
machines
- #14165 Endless client blocking for blocking commands
- #14164 Prevent `CLIENT UNBLOCK` from unblocking `CLIENT PAUSE`
- #14216 TTL was not removed by the `SET` command
- #14224 `HINCRBYFLOAT` removes field expiration on replica

### Performance and resource utilization improvements (compared to
8.2-RC1)

- #14200 Store iterators on stack instead of on heap
- #14144 Vector set - improve RDB loading / RESTORE speed by storing the
worst link info
- #Q6430 More compression variants for the SVS-VAMANA vector index
- #Q6535 `SHARD_K_RATIO` parameter - favor network latency over accuracy
for KNN vector query in a Redis cluster (unstable feature) (MOD-10359)

### Modules API

- #14051 `RedisModule_Get*`, `RedisModule_Set*` - allow modules to
access Redis configurations
- #14114 `RM_UnsubscribeFromKeyspaceEvents` - unregister a module from
specific keyspace notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes state:needs-doc-pr requires a PR to redis-doc repository

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants