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

chore: allow config set notify_keyspace_events #3790

Merged
merged 2 commits into from
Sep 30, 2024
Merged

chore: allow config set notify_keyspace_events #3790

merged 2 commits into from
Sep 30, 2024

Conversation

kostasrim
Copy link
Contributor

@kostasrim kostasrim commented Sep 25, 2024

We do not allow notify_keyspace_events to be set at runtime via config set command. This PR addresses this.

  • allow notify_keyspace_events in config set command
  • add tests

Resolves #3708

@kostasrim kostasrim self-assigned this Sep 25, 2024
Comment on lines +514 to +516
// Does not check for non supported events. Callers must parse the string and reject it
// if it's not empty and not EX.
void SetNotifyKeyspaceEvents(std::string_view notify_keyspace_events);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks fragile 🤓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree but it's only meant to be used in the callback of config set command. There is no real reason to do the parsing here...

Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

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

Forgot to push that comment

Comment on lines 1454 to 1460
void DbSlice::SetNotifyKeyspaceEvents(std::string_view notify_keyspace_events) {
if (notify_keyspace_events.empty()) {
for (auto& db : db_arr_) {
db->expired_keys_events_.clear();
}
}
expired_keys_events_recording_ = !notify_keyspace_events.empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure it's important, but there are lots of small questions about correctness 🤷🏻‍♂️ Is this change transactional? Do we really discard all previous events? etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good questions! config set is not transactional so why would this be an exception? Sure you might argue that for certain transactions there might be events that are "lost" but I would say this is fine + the only solution for this would be to make it a global transaction which I don't think it would be a great idea 🤷‍♂️

As for discarding for all previous events that's something I should check with Valkey. I will get back to you for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dranikpg I did check how it's implemented in Valkey.

  1. It does not clear the current keyspace events. So I will address this in a second and push.
  2. For transactions, yes it's "racy" if the keyspace events are disabled. So for certain transactions they might not include all the keyspace events for expirations but I would say this is fine. CONFIG SET is not transactional so 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if you have any other thoughts

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, if it's racy, let it be racy for us as well 🤷🏻 🙂

dranikpg
dranikpg previously approved these changes Sep 25, 2024
Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

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

If we're ok with no safety checks and correctness questions 🙂

@kostasrim kostasrim merged commit ed11c8d into main Sep 30, 2024
12 checks passed
@kostasrim kostasrim deleted the kpr1 branch September 30, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Additional request around notify-keyspace-events to support Spring Data
2 participants