-
Notifications
You must be signed in to change notification settings - Fork 753
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
Support Blocking a Client on Keyspace Event Notification #1819
base: unstable
Are you sure you want to change the base?
Conversation
a064f39
to
74cb5e4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1819 +/- ##
============================================
- Coverage 70.99% 70.99% -0.01%
============================================
Files 123 123
Lines 65651 65707 +56
============================================
+ Hits 46609 46648 +39
- Misses 19042 19059 +17
🚀 New features to boost your workflow:
|
2428ae0
to
7c9cff2
Compare
dd60c6a
to
0445d46
Compare
This change enhances user experience and consistency by allowing a module to block a client on keyspace event notifications. Consistency is improved by ensuring that reads after writes on the same connection yield expected results. For example, in ValkeySearch, mutations processed earlier on the same connection will be available for search. The implementation extends `VM_BlockClient` to support blocking clients on keyspace event notifications. Internal clients, LUA clients, clients issueing multi exec and those with the `deny_blocking` flag set are not blocked. Once blocked, a client’s reply is withheld until it is explicitly unblocked. Signed-off-by: yairgott <[email protected]>
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.
Ok, I'm aligned with the design now. Just some other misc comments.
Co-authored-by: Madelyn Olson <[email protected]> Signed-off-by: Yair Gottdenker <[email protected]>
Co-authored-by: Madelyn Olson <[email protected]> Signed-off-by: Yair Gottdenker <[email protected]> Signed-off-by: yairgott <[email protected]>
@valkey-io/core-team This API is a bit late to be added. The feature adds a new functionality to using keyspace notifications, allowing them to block clients. The goal is to provide read and after write consistency for the VSS module. There are two different ways to provide this guarantee, either block the write until it's visible in the index or block the read until all pending writes were ingested. The search module preferred to use the blocking of the write approach, but need an API to block the writes. @murphyjacob4 Will follow up to see if there is a away to avoid this new functionality. |
@@ -112,7 +113,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) { | |||
* This bypasses the notifications configuration, but the module engine | |||
* will only call event subscribers if the event type matches the types | |||
* they are interested in. */ | |||
moduleNotifyKeyspaceEvent(type, event, key, dbid); | |||
moduleNotifyKeyspaceEvent(c, type, event, key, dbid); |
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.
Can you simply use server.current_client
when you invoke this method? That way you don't need to pass in client*
into notifyKeyspaceEvent()
.
@@ -8880,8 +8924,14 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) | |||
if ((sub->event_mask & type) && | |||
(sub->active == 0 || (sub->module->options & VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS))) { | |||
ValkeyModuleCtx ctx; | |||
moduleCreateContext(&ctx, sub->module, VALKEYMODULE_CTX_TEMP_CLIENT); | |||
selectDb(ctx.client, dbid); | |||
if (c == NULL) { |
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.
Rather than passing in client*
to this module API, can you simply check if server.current_client
is NULL or not?
Or... maybe check server.executing_client
if you want to cover the case of a Lua script.
This change enhances user experience and consistency by allowing a module to block a client on keyspace event notifications. Consistency is improved by allowing that reads after writes on the same connection yield expected results. For example, in ValkeySearch, mutations processed earlier on the same connection will be available for search.
The implementation extends
VM_BlockClient
to support blocking clients on keyspace event notifications. Internal clients, LUA clients, clients issueing multi exec and those with thedeny_blocking
flag set are not blocked. Once blocked, a client’s reply is withheld until it is explicitly unblocked.