Tracking: add CLIENT TRACKINGINFO subcommand#7309
Conversation
|
@soloestoy this informmation is very useful, I was trying to do the impementation also.. However I noticed there is no such APIs for supporting like a CLIENT INFO command, which I would think like showing current info of the single client in CLIENT LIST command, we can put the tracking information there and showing some extras that we may interested with. How do you think? |
|
One of the reason I can think of splitting the information only for that client from CLIENT LIST is we may put an ACL rules on this, to isolate user can only see the current client status |
|
I agree with @hwware. I like the idea of adding this to client list as tracking flags, tracking prefixes, and redirect client. I'm not convinced about the utility of client info though, that could come later though. |
31f07fe to
331303a
Compare
|
ping @oranagra , PR updated. |
oranagra
left a comment
There was a problem hiding this comment.
seems good to me.
i think a test for partial coverage is needed.
331303a to
f387799
Compare
src/networking.c
Outdated
There was a problem hiding this comment.
I don't really get this section as much, I think it would be clearer to have the states:
caching-enabled: optin/optout/off
next-key-cached: yes/no or optin-optout
From a debugging perspective this seems like the most clear.
There was a problem hiding this comment.
optin/optout is already in flags, so I just rename the caching-enabled to next-key-cached
|
+1 on at least adding this check to some of the tests. |
|
@soloestoy can you please add some basic coverage test and respond to Madelyn's comments? |
|
ok @oranagra I will update it soom |
f387799 to
f0ad401
Compare
f0ad401 to
6caf327
Compare
src/networking.c
Outdated
There was a problem hiding this comment.
for some reason this still feels odd to me.
maybe it's the new term ("next-key-cached") which i guess isn't yet used anywhere (we probably wanna be consistent with either the commands or existing documentation).
and maybe also the fact that the 'yes' and 'no' values come from so many different sources, it would be hard to reconstruct the state of the configuration. maybe we need 6 unique strings?
or was the whole purpose of this specific field to be easily used?
i.e. the caller knows what's gonna happen on the very next command, rather than understanding the various configurations (if that's the case, i'm not sure it's needed, the caller of the TRACKING command should understand the tracking options).
that said, i'm no CSC expert, i'll ask that others who are will comment.
There was a problem hiding this comment.
The term we use in the documentation is opt-in caching. My problem is the output is hard to digest without looking at other fields.
If we don't want to show the flags, maybe this is easy?
"next-command-cached": "Opt-in", "Opt-out", "tracking", "off"
There was a problem hiding this comment.
i agree with @madolson , the caching flag is only valid for Opt-in Opt-out mode, how about we put this together with the opt-in opt-out tracking flags? maybe we don't need to show it separately here, instead we can show in the flags field? like we do the similar logic here in the flags part but add caching/no-caching instead of yes or no.
6caf327 to
42007c8
Compare
|
Hi all, I modify the PR, show the original info based on |
|
@redis/core-team please review & approve. |
|
@soloestoy while documenting this I had some late reservations, specifically:
|
|
The best option I could come up with, was to collapse the last two states to this: This is part of the opt-in caching feature to reflect the current state of the next command. The intention is for this to give a user visible value for the CLIENT_TRACKING_CACHING flag. Either that, or we just add it to the flags like @hwware mentioned, and users can figure it out. @redis/core-team thoughts? |
|
@madolson your proposal seems somewhat in line with what Zhao implemented in the past: /* Caching */
addReplyBulkCString(c,"next-key-cached");
if (c->flags & CLIENT_TRACKING_OPTIN) {
addReplyBulkCString(c,c->flags & CLIENT_TRACKING_CACHING ? "yes" : "no");
} else if (c->flags & CLIENT_TRACKING_OPTOUT) {
addReplyBulkCString(c,c->flags & CLIENT_TRACKING_CACHING ? "no" : "yes");
} else {
addReplyBulkCString(c,c->flags & CLIENT_TRACKING ? "yes" : "no");
}I suppose the fact it was later split in this PR into two fields (which are a reflection of the flags already present) was a mistake, and the purpose you state (to give the user something easy to read) is right. as far as i can tell, for OPT_IN both implementations will give similar result: "yes"=>"opt-in", "no"=>"none". bottom line, this approach seems ok to me, i'm just trying to put everything on the table to make sure we're not overlooking something. |
|
Yeah, it's very similar to what was originally implemented, with a couple of key differences:
For background information on this feature, this feature sets a default behavior for tracking, that is what the opt-in and opt-out flags are for. Executing the "CLIENT CACHING YES/NO" allows you to override that default behavior for the next command, this state is stored in the CLIENT_TRACKING_CACHING flag. We could just show this flag, which was Wen's suggestion, but it can have multiple meanings, so I think adding a little more context is useful. That being said, I don't think we need a lot of more context since other flags are listed above. |
|
ohh, now i finally understand (and being lazy and/or overloaded, only now i finally bothered to look at the redis code). sorry about that. this so trying to put it in my own words, both of these above pasted implementations are right. the first one stats if the "override" is currently enabled, and the second one says if the next command is gonna cache or not. (sorry for repeating your words) this really sucks. i don't particularly like either of them 8-( i wanna suggest a 3rd one (which is kinda similar to your last suggestion, but i think sticks to the redis awkward command terminology).
if you also like it, let me know. |
|
Moving it to a flag seems fine. I still think the command that enables the feature, CLIENT CACHING [YES|NO], is confusing and I would prefer to do something that makes it more readable: ["optin"] - opt-in with no override If you feel we should keep exactly redis wording, I think what you proposed is okay too. |
|
i'd rather keep to the existing terminology (would be easier to document). |
|
My vote would be for caching-yes/caching-no, since those at least seem like flags. So this will be the code? It'll replace the existing flag code for option and output. |
bf3a342
oranagra
left a comment
There was a problem hiding this comment.
@redis/core-team please review bf3a342 and approve.
@itamarhaber if you agree, please update the redis-doc PR
|
Agreed and updated doc |
Add CLIENT TRACKINGINFO subcommand Co-authored-by: Oran Agra <[email protected]>
Now we have a lot of options for client tracking, I think we need a way to show the tracking status.
This PR reply an txt, maybe map is better, not sure.