Skip to content
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 a key update notification #1144

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from
Open

Conversation

jjz921024
Copy link

this pr want to close #1143

src/server.c Outdated
@@ -3537,6 +3537,10 @@ void call(client *c, int flags) {
dirty = server.dirty - dirty;
if (dirty < 0) dirty = 0;

if (dirty > 0) {
notifyKeyspaceEvent(NOTIFY_DIRTY, "dirty", c->argv[1], c->db->id);
Copy link
Member

@ranshid ranshid Oct 10, 2024

Choose a reason for hiding this comment

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

This will not target specific key, but only indicate the dataset is dirty, there are many multi key commands (like mset, eval etc...) which will make many keys dirty. I think maybe a better place is to place it in signalModifiedKey

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your guidance. I had put it in signalModifiedKey.

src/notify.c Outdated
@@ -58,6 +58,7 @@ int keyspaceEventsStringToFlags(char *classes) {
case 'm': flags |= NOTIFY_KEY_MISS; break;
case 'd': flags |= NOTIFY_MODULE; break;
case 'n': flags |= NOTIFY_NEW; break;
case 'c': flags |= NOTIFY_DIRTY; break;
Copy link
Member

@ranshid ranshid Oct 10, 2024

Choose a reason for hiding this comment

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

Personally I do not find the 'dirty' as the correct state here. IMO dirty means that the key was modified and was not yet consisted (like for example successfully written to the replica).
Although funny name but maybe: NOTIFY_MODIFY is a better match for what really happened?
Also maybe NOTIFY_UPDATE?

Copy link
Author

@jjz921024 jjz921024 Oct 11, 2024

Choose a reason for hiding this comment

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

I perfer NOTIFY_UPDATE, because we can use 'u' to stand it. (The letter 'm' has been used)

src/config.c Outdated
@@ -2906,7 +2906,7 @@ static int setConfigNotifyKeyspaceEventsOption(standardConfig *config, sds *argv
}
int flags = keyspaceEventsStringToFlags(argv[0]);
if (flags == -1) {
*err = "Invalid event class character. Use 'Ag$lshzxeKEtmdn'.";
*err = "Invalid event class character. Use 'Ag$lshzxeKEtmdnc'.";
Copy link
Member

Choose a reason for hiding this comment

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

why 'c'? maybe 'u' (stands for updated)?

@ranshid
Copy link
Member

ranshid commented Oct 10, 2024

@jjz921024 you will have to sign your commit in order for the DCO to pass.

@jjz921024 jjz921024 changed the title Add a dirty key notification Add a key update notification Oct 11, 2024
Signed-off-by: anotherJJz <[email protected]>
@ranshid ranshid added the major-decision-pending Major decision pending by TSC team label Oct 13, 2024
@ranshid
Copy link
Member

ranshid commented Oct 13, 2024

@valkey-io/core-team since this is an interface/config change, tagged it as major decision. can you please take a look?

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.63%. Comparing base (9b8a061) to head (dcdcfb1).
Report is 5 commits behind head on unstable.

Files with missing lines Patch % Lines
src/notify.c 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1144      +/-   ##
============================================
- Coverage     70.67%   70.63%   -0.04%     
============================================
  Files           114      114              
  Lines         61717    61678      -39     
============================================
- Hits          43617    43568      -49     
- Misses        18100    18110      +10     
Files with missing lines Coverage Δ
src/config.c 78.64% <100.00%> (-0.06%) ⬇️
src/db.c 88.42% <100.00%> (ø)
src/server.h 100.00% <ø> (ø)
src/notify.c 95.65% <50.00%> (-1.37%) ⬇️

... and 43 files with indirect coverage changes

@PingXie
Copy link
Member

PingXie commented Oct 14, 2024

@valkey-io/core-team since this is an interface/config change, tagged it as major decision. can you please take a look?

How is this new setting different from g$lshzxet (or just g$lshzxe if stream events are not interesting)? Are there any specific updates that are not covered by the existing event types? The way it is implemented now seems to be a super set of the existing event types.

@ranshid
Copy link
Member

ranshid commented Oct 15, 2024

@valkey-io/core-team since this is an interface/config change, tagged it as major decision. can you please take a look?

How is this new setting different from g$lshzxet (or just g$lshzxe if stream events are not interesting)? Are there any specific updates that are not covered by the existing event types? The way it is implemented now seems to be a super set of the existing event types.

I agree. this will basically aggregate different events under the same event name. mainly to simplify the client side logic and can be achieved without this. However that got me thinking if we see any value to provide some "update" notification indicating an existing value was changed (as apposed to created/deleted/expired etc...). however that would require a different change introduced.

@jjz921024
Copy link
Author

jjz921024 commented Oct 15, 2024

@valkey-io/core-team since this is an interface/config change, tagged it as major decision. can you please take a look?

How is this new setting different from g$lshzxet (or just g$lshzxe if stream events are not interesting)? Are there any specific updates that are not covered by the existing event types? The way it is implemented now seems to be a super set of the existing event types.

@PingXie Hi, It might be different with g$lshzxet. The existing event type does not contain events for which the key is modified. Please let me know if I'm wrong.

@jjz921024
Copy link
Author

@valkey-io/core-team since this is an interface/config change, tagged it as major decision. can you please take a look?

How is this new setting different from g$lshzxet (or just g$lshzxe if stream events are not interesting)? Are there any specific updates that are not covered by the existing event types? The way it is implemented now seems to be a super set of the existing event types.

I agree. this will basically aggregate different events under the same event name. mainly to simplify the client side logic and can be achieved without this. However that got me thinking if we see any value to provide some "update" notification indicating an existing value was changed (as apposed to created/deleted/expired etc...). however that would require a different change introduced.

@ranshid Hi, It will aggregate different events under the same event name. But, if we want to provide update notification when a key has been modify. Maybe we should introduce it.

@PingXie
Copy link
Member

PingXie commented Oct 15, 2024

The existing event type does not contain events for which the key is modified. Please let me know if I'm wrong

I assume you meant "value modification" rather than "key modification" here? The current key notification mechanism breaks events down by data/command types like SET, HSET, etc. From my quick look at the source code, it appears to cover all relevant operations. Are you seeing any "update" operations being missed? I'm cautious about introducing another "superset" event, as it might add unnecessary complexity/overhead.

BTW, we do have "rename" (or "key modification") events too.

@ranshid
Copy link
Member

ranshid commented Oct 15, 2024

BTW, we do have "rename" (or "key modification") events too.

Yes we do. we have rename_from and rename_to events

@ranshid
Copy link
Member

ranshid commented Oct 15, 2024

The existing event type does not contain events for which the key is modified. Please let me know if I'm wrong

I assume you meant "value modification" rather than "key modification" here? The current key notification mechanism breaks events down by data/command types like SET, HSET, etc. From my quick look at the source code, it appears to cover all relevant operations. Are you seeing any "update" operations being missed? I'm cautious about introducing another "superset" event, as it might add unnecessary complexity/overhead.

I think, as @PingXie correctly stated, that the current events ARE reflecting most of the mutative data commands. However currently there is not easy way for the client to understand a VALUE was changed other then combining the "new" notification and all other different events which are per operation/datatype. I think it might simplify the client logic to be able to have event notification for "modified" value but as I said this IS currently possible to achieve by clients IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-decision-pending Major decision pending by TSC team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NEW] Add a dirty key notification
3 participants