Skip to content

Receive notification for SET and DEL events on replicas (minimal implementation of notify-keyspace-events) #2915

@clickfreak

Description

@clickfreak

Search before asking

  • I had searched in the issues and found no similar issues.

Motivation

Applications connected to the KVRocks read-only replica use their own cache to reduce response latency and minimize direct requests to KVRocks. However, the application must react to key changes in order to provide up-to-date responses.

We don’t use TTLs for keys and don’t expect key expiration events — this is also difficult to implement due to the nature of the KVRocks underlying storage (rocksdb). As minimum we need to react on SET and DEL commands, apps itself can control the subscription using PSUBSCRIBE and PUNSUBSCRIBE commands, it will allow to replace Redis/Valkey with minimal effort.

KVRocks is excellent for distributing data across the fleet without wasting RAM, and it’s a very strong candidate to replace our current Redis storage. Keyspace events are the last missing piece preventing us from fully switching from Redis/Valkey to KVRocks.

Solution

From what I understand, KVRocks uses a WAL internally to replicate changes. This means that when the WAL is applied on replicas, it should be possible to detect key changes and emit events to applications with subscriptions by pattern (PSUBSCRIBE/PUNSUBSCRIBE).

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions