Conversation
itamarhaber
left a comment
There was a problem hiding this comment.
I like the enhancement, but I'm not sure about the implementation style. Also, there are some edge cases, for example, INFO default all will return "all".
|
@itamarhaber Hi Itamar, thanks for your comment, the |
189d87e to
f8d8d17
Compare
|
@yossigo, Can you please take a look at this PR. This is a old PR but I think it is still useful and valid. I have rebased the code for this PR to remove any conflicts. Thanks |
oranagra
left a comment
There was a problem hiding this comment.
i always wanted to do that, so i do support the cause, but i don't like the implementation.
it's nice that the implementation attempts to make a small diff by repeatedly calling genRedisInfoString rather than modifying all the section checks in that function, but i think we have to go that way anyway since the current approach is limited.
another thing to consider is backwards compatibility, in the sense of what would happen if someone tries to call INFO memory replication on an older version of redis.
calling it with multiple arguments (or a single argument with spaces in it) will fail, so for many tools that manage redis servers and can't be sure which version they're talking to, using this feature is not an option.
859d242 to
422596f
Compare
|
Hey @oranagra, I have updated the code for this PR and editted the top comment for description. Please take a look. |
oranagra
left a comment
There was a problem hiding this comment.
@hwware sorry about the delay.
i must say i don't like this approach.
the default sections are now defined in two places (both inside genRedisInfoString and in the list in infoCommand).
normally, it has two loops on all the arguments (in infoCommand), and then another loop on the dict it generates.
and it calls genRedisInfoString multiple times, each call ends up doing many string compares.
what's nice about your approach is that you managed to do it without a single change to genRedisInfoString, but i don't think that's a real concern.
what i imagine should be done instead, is pass the dict to genRedisInfoString (calling it only once), and change all the section checks in genRedisInfoString to use dictFind.
similar logic needs to be implemented in RM_InfoAddSection (i already designed the API with that feature of multiple sections in mind).
i think the two loops on argc can be unified into one, which will result in a dict and two boolean flags (all and everything, which will be passed to genRedisInfoString as argument along side the dict).
the list of default sections will be present only once in the source code (in infoCommand), and will be added to the dict in case no arguments are provided, or the term "default" was specified.
let me know what you think.
p.s. your current approach won't play nice with modules, since RM_InfoAddSection can include a certain section both by module name filter and section name filter (so there's a change the same section will appear twice if it is present in the dict twice)
|
Hey @oranagra, I agree with your suggesions. I have some questions about the implementation.
|
|
yes, the loop will add the individual default sections ( |
a9e4b4e to
f99bb3a
Compare
oranagra
left a comment
There was a problem hiding this comment.
@hwware are you still working on this PR?
It seems you where either unable to follow my advises or run into some problems that i didn't expect and can't figure out.
do you wanna proceed or want me to try pick it up on my own?
after investing the effort so far, i think we should carry it though.
Hi Oran, I am still working on this. I will let you know when my codes update. Thanks a lot. |
|
@oranagra Hi Oran, I just finish the code refactor according to your suggestion. You could find the following changes:
|
oranagra
left a comment
There was a problem hiding this comment.
i took a quick look.
i didn't review the diff from last time (too much back and forth)
but rather re-read the diff of the current version vs unstable.
it's a little bit closer to what i suggested, but there are a few bugs, styling issues, and most importantly the handling of sentinel default sections and requested sections sanitization isn't what we agreed.
i assume all the old comments can be dismissed now (please go over them and dismiss them unless you notice some observation that was forgotten)
p.s. i suppose some tests are needed for both the happy path, and some edge cases.
* Update test cases * Minor changes * Update 05-manual.tcl * Update 10-replica-priority.tcl
* Update test cases for sentinel (#12) * Update test cases * Minor changes * Update 05-manual.tcl * Update 10-replica-priority.tcl * Update 07-down-conditions.tcl * Update ci.yml * Update ci.yml * Update to test 7 and ci * Update 07-down-conditions.tcl * Delete 07-down-conditions.tcl * Create 07-down-conditions.tcl * Update 07-down-conditions.tcl
@oranagra As we discussed, I update the c->argv+2 and c->argc-2 to c->argv+1 and c->argc-1 to fix the minor bug, now in sentinel mode, "info" command run well, and I add more test cases for "info", "info all", "info default" and "info everything" commands, and I also add some test cases for "info + one subsection or multiple sections" for redis server mode and sentinel mode. Please take a look and Thanks for your great help. |
|
@redis/core-team please approve, changing INFO to take multiple sections. |
yossigo
left a comment
There was a problem hiding this comment.
LGTM, one potential optimization to consider.
|
I've benchmarked this PR against unstable, with the plain INFO command (no args). |
|
scrap all that, the regression was due to the accidental inclusion of the
|
|
my final version:
unstable:
|
madolson
left a comment
There was a problem hiding this comment.
Approve of the API, just some minor comments.
Introduced in redis#6891
* Fix INFO SENTINEL memory leak Introduced in #6891 * remove the copy-paste sentence
The problem/use-case that the feature addresses
This is an enhancement for INFO command, previously INFO only support one argument for different info section , if user want to get more categories information, either perform INFO all/default or calling INFO for multiple times.
Description of the feature
The goal of adding this feature is to let the user retrieve multiple categories via the INFO command, and still avoid emitting the same section twice.
A use case for this is like Redis Sentinel, which periodically calling INFO command to refresh info from monitored Master/Slaves, only Server and Replication part categories are used for parsing information.
If the INFO command can return just enough categories that client side needs, it can save a lot of time for client side parsing it as well as network bandwidth.
Implementation
To share code between redis, sentinel, and other users of INFO (DEBUG and modules), we have a new
genInfoSectionDictfunction that returns a dict and some boolean flags (e.g.all) to the caller (built from user input).Sentinel is later purging unwanted sections from that, and then it is forwarded to the info
genRedisInfoString.Usage Examples
INFO Server Replication
INFO CPU Memory
INFO default commandstats