-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Add new KSN types - overwritten and type_changed #14141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new KSN types - overwritten and type_changed #14141
Conversation
🎉 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) |
|
I saw that some *store command (similar to SUNIONSTORE) were not mentioned, which all use |
|
i can't afford to review the code at the moment, commenting on the description. Is this PR only for module KSN hooks? or also for pubsub? i think it makes sense to cover both (unless we wanna keep the scope small due to lack of time). let's make it clear in the description, and if it covers pubsub, we need to document the syntax.
maybe list other commands like GEORADIUS and SUNIONSTORE? just for completeness.
does SETRANGE in such case resets the TTL or LFU? i don't think so, in which case it's an update not an overwrite. |
Should we add tests for each such command, or did u only mean to add in the description as oran said ? |
only add them in the top comment, maybe it would be better if there were tests. |
|
please document a usage example of both module API and pubsub in the description. |
|
@oranagra Yes, we're also going to need to update the docs. Let me know if the new description with examples is satisfactory. |
added with 1fd74f0 |
|
LGTM. do we also generate a keyspace event, in addition to the key event? |
|
@oranagra yes, of course, since |
|
Docs PR |
sundb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LGTM (based on skimming over the interfaces and docs). |
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
What
Add new keyspace notification event types
Used in Pub/Sub KSN mechanism. Also added module hooks for the new types.
Motivation
Many commands overwrite the value of a key. F.e SET completely overwrites the value of any key, even its type. Other commands that have the REPLACE parameter also do so.
This commit gives more granularity over following such events.
Specific use-case at hand was module that is subscribed to string events for the sole purpose of checking if hash keys get converted to strings via the
SETcommand. Subscribing totype_changedevent not only removes the need to subscribe to string events but is also more correct as not onlySETcan change the type of a key.List of commands emitting the new events
Each type with STORE operation:
Usage example
pub-sub
Emit overwritten and type-changed events...
Generate an overwritten event that also changes the type of a key...
Subscribe to the events...
Modules
As with any other KSN type subscribe to the appropriate events
Implementation notes
Most of the cases are handled in
setKeyByLinkbut for some commands overwriting had to be manually checked - specificallyRESTORE,COPYandRENAMEmanually calldbAddInternal