-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Add CLIENT NO-TOUCH for clients to run commands without affecting LRU/LFU of keys #11483
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
Conversation
zuiderkwast
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.
Cool feature.
If found one more call to lookupKeyReadWithFlags without the NOTOUCH flag, in blocked.c, function handleClientsBlockedOnKeys:
/* Serve clients blocked on the key. */
robj *o = lookupKeyReadWithFlags(rl->db, rl->key, LOOKUP_NONOTIFY | LOOKUP_NOSTATS);What do you think about this one? If the key just became ready, it must have just been written and therefore just touched, so touching it again doesn't hurt? But then we could as well add the NOTOUCH flag here...
madolson
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.
Would you mind adding a simple test that it works? Probably in unit/introspection-2
This is where I got confused. The |
this is introduce by #9572, do you remember why change it from lookup write to read @zuiderkwast ? BTW, every time I see writable replica I still have to say I hate it, it messes things up. |
@soloestoy (regarding the lookup in lookupKeyReadWithFlags) I don't remember why but I guess we changed it to preserve the old behaviour when we changed lookupKey. Anyway, this lookup is not a normal lookup since it's not for a specific client. Later, each key will be looked up again for a specific client and command. Let's just add NOTOUCH here (or change it so it doesn't use lookupKey at all). Btw, I don't want to talk about writeable replicas. They're not fun. 😁 |
but if it's lfu, we should touch the object to increase the frequency...
I don't get your point about "each key will be looked up again for a specific client and command", for example |
@soloestoy You're right... but BLPOP only blocks if the key doesn't exist though. If the key is created by another client using LPUSH, there is no LRU/LFU stored when our client is unblocked. I guess we do want to increment LRU/LFU for BLPOP when popping... |
|
So regarding the |
|
Just had another thought: in the orginal issue #11409, we only need a stealth/no-touch mode for read operations, but should we limit it in read operations? Or is it ok to perform write operations without touching LRU/LFU stats? If stealth/no-touch mode can also apply to write operations, it is easier to implement. @madolson WDYT? |
Is it useful or confusing? If stealth mode is a kind of super-readonly mode that shouldn't do any changes to keys, then we should probably return an error for write commands. If it is a useful hack for administrators, then we can allow no-touch for write operations too... |
|
Discussed in the core meeting. Discussion was to decouple the stealth mode conversation, and proceed with this PR as is. Folks should take a look shortly. |
|
@soloestoy Do you still plan on following up on this? I can help close on this if you are busy. |
oranagra
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.
sorry for the long delay. forgot about it....
mostly LGTM, here are some minor comments.
madolson
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.
Minor comments as well, looks OK to me.
Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com>
|
@CharlesChen888 can you please make a redis-doc PR as well? |
|
@oranagra of course, I'm already writing it. |
|
i wonder if we should mention the change about NO-EVICT in the docs somewhere? |
Co-authored-by: sundb <sundbcn@gmail.com>
@oranagra I think we need to doc the change of |
|
@CharlesChen888 my question was about documenting the history. i.e. mention that in redis 7.0 we didn't reset the no-evict and in 7.2 we do.. |
CLIENT NO-TOUCH added in redis#11483, but forgot to add the since field in the JSON file. This PR adds the since field to it with a value of 7.2.0
CLIENT NO-TOUCH added in #11483, but forgot to add the since field in the JSON file. This PR adds the since field to it with a value of 7.2.0
…/LFU of keys (redis#11483) When no-touch mode is enabled, the client will not touch LRU/LFU of the keys it accesses, except when executing command `TOUCH`. This allows inspecting or modifying the key-space without affecting their eviction. Changes: - A command `CLIENT NO-TOUCH ON|OFF` to switch on and off this mode. - A client flag `#define CLIENT_NOTOUCH (1ULL<<45)`, which can be shown with `CLIENT INFO`, by the letter "T" in the "flags" field. - Clear `NO-TOUCH` flag in `clearClientConnectionState`, which is used by `RESET` command and resetting temp clients used by modules. - Also clear `NO-EVICT` flag in `clearClientConnectionState`, this might have been an oversight, spotted by @madolson. - A test using `DEBUG OBJECT` command to verify that LRU stat is not touched when no-touch mode is on. Co-authored-by: chentianjie <chentianjie@alibaba-inc.com> Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com> Co-authored-by: sundb <sundbcn@gmail.com>
CLIENT NO-TOUCH added in redis#11483, but forgot to add the since field in the JSON file. This PR adds the since field to it with a value of 7.2.0
no-evict added in redis/redis#8687 no-touch added in redis/redis#11483 Co-authored-by: Binbin <binloveplau1314@qq.com>
To resolve #11409
When no-touch mode is enabled, the client will not touch LRU/LFU of the keys it accesses, except when executing command
TOUCH.This allows inspecting or modifying the key-space without affecting their eviction.
Changes:
CLIENT NO-TOUCH ON|OFFto switch on and off this mode.#define CLIENT_NOTOUCH (1ULL<<45), which can be shown withCLIENT INFO, by the letter "T" in the "flags" field.NO-TOUCHflag inclearClientConnectionState, which is used byRESETcommand and resetting temp clients used by modules.NO-EVICTflag inclearClientConnectionState, this might have been an oversight, spotted by @madolson.DEBUG OBJECTcommand to verify that LRU stat is not touched when no-touch mode is on.