-
Notifications
You must be signed in to change notification settings - Fork 24.4k
redis-cli generates command help tables from the results of COMMAND #10043
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
|
thanks for your PR.. started looking at it.. |
|
Right - that would mean keeping the existing help.h mechanism as a fallback for when COMMAND returns the old format. Basically, keep all the code this PR deletes, behind a conditional. We could keep it for a predefined transition period, until the old server version is no longer supported. But sure, it would complicate the code. |
|
ok. i don't like it.. but just wanted to raise it. |
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.
@jhelbaum i did a sloppy initial review (only looking at the diff, without being familiar of the code that uses it).
can't afford to spend much more time on that right now, so i figured raw feedback is better than nothing.
|
for the record, i guess it's not so bad if a new redis-cli doesn't show hints when running with an old redis server (I would imagine the more common case is an old redis-cli with an new redis-server) |
|
i'm not sure that's right.. someone managing many redis servers, will maybe update his redis-cli but keep using it for both old and new servers. |
|
Can redis-cli assume that COMMAND INFO and COMMAND DOCS return the commands in the same order? It would simplify the code. |
|
currently that's the case, and i can't think of any reason why the implementation could be changed in a way that'll break that. |
if-else style Co-authored-by: Oran Agra <oran@redislabs.com>
58be967 to
bb63d64
Compare
|
COMMAND INFO is not necessary for this purpose. The code now only calls COMMAND DOCS, which has all the relevant information for the help strings. |
|
@jhelbaum forgive me for the luck of focus. what's the status here? |
|
As far as I'm concerned, it's ready. I don't get the sense that it's had a
thorough code review, though.
I also don't know if there are any tests that are usually run on redis-cli?
…On Tue, Jan 25, 2022 at 5:19 PM Oran Agra ***@***.***> wrote:
@jhelbaum <https://github.com/jhelbaum> forgive me for the luck of focus.
what's the status here?
ready for merge?
—
Reply to this email directly, view it on GitHub
<#10043 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH5PZMMIUZWP4QOM7NY3XBDUX25QBANCNFSM5LE7HCOQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
I'll give it another review.. just wasn't sure there are still changes pending or it's ready from your side. |
|
Another thought: Presumably in a separate PR, would anyone object to breaking this up into multiple files? 8800 lines is a bit much much for one source file. |
|
i agree. but i don't see a point in just breaking it up in a PR that does only that.. |
|
Okay, I've reinstated the static help.h file for use with pre-7.0 servers, along with the code that generates the help tables from it. I still can't figure out why some of the tests are timing out. Any leads in investigating the problem would be appreciated. |
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.
just a quick skim though the recent changes.
|
I can't figure out why the test hangs on GH actions (it passes locally). |
|
It's been broken since at least 896dad5 |
|
it was actually easy to reproduce locally if using the same |
|
p.s. so when you call |
|
Okay, I've learned something. Thanks.
…On Fri, Feb 4, 2022, 16:38 Oran Agra ***@***.***> wrote:
p.s. zrealloc uses realloc, but has this in smalloc.c:
#define realloc(ptr,size) je_realloc(ptr,size)
so when you call realloc from redis-cli.c, it uses libc allocator.
but if you debug this with make valgrind or any system that doesn't use
jemalloc by default, then both use libc, which is why it didn't reproduce
locally for you.
—
Reply to this email directly, view it on GitHub
<#10043 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH5PZMOG2ZROREBE3VS4F63UZPQHNANCNFSM5LE7HCOQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Maybe we should automatically hide suggestions based on version? |
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.
for the record, some tests i did (with valgrind).
- run it against latest server and against old server.
- added to both servers some commands that don't exist in help.h, and verified they show in
helpand in completion hints. - run it with and without
-3 - verified the help
@<cat>is working
the only problem i could spot (which may not be an issue), is that when using help.h (on old server) we show the since field, but when using COMMAND DOCS (new server) we don't.
it's logical since when we use COMMAND DOCS we show only the ones actually supported.
but since the users can't distinguish between these modes, i now think it'll be nicer to show it in both modes.
Because SENTINEL DEBUG missing summary in its json file, with the change in redis#10043, the following assertion will fail. ``` [redis]# src/redis-cli -p 26379 redis-cli: redis-cli.c:678: cliInitCommandHelpEntry: Assertion `reply->type == 1' failed. ``` This commit add the summary and complexity for SENTINEL DEBUG, which introduced in redis#9291, and also improved the help message.
…ry (#10250) Fix redis-cli with sentinel crash due to SENTINEL DEBUG missing summary Because SENTINEL DEBUG missing summary in its json file, with the change in #10043, the following assertion will fail. ``` [redis]# src/redis-cli -p 26379 redis-cli: redis-cli.c:678: cliInitCommandHelpEntry: Assertion `reply->type == 1' failed. ``` This commit add the summary and complexity for SENTINEL DEBUG, which introduced in #9291, and also improved the help message.
If summary or since is empty, we used to return NULL in COMMAND DOCS. Currently all redis commands will have these two fields. But not for module command, summary and since are optional for RM_SetCommandInfo. With the change in redis#10043, if a module command doesn't have the summary or since, redis-cli will crash (see redis#10250). In this commit, COMMAND DOCS avoid adding summary or since when they are missing.
If summary or since is empty, we used to return NULL in COMMAND DOCS. Currently all redis commands will have these two fields. But not for module command, summary and since are optional for RM_SetCommandInfo. With the change in #10043, if a module command doesn't have the summary or since, redis-cli will crash (see #10250). In this commit, COMMAND DOCS avoid adding summary or since when they are missing.
The following usage will output an empty newline: ``` > redis-cli help set empty line ``` The reason is that in interactive mode, we have called `cliInitHelp`, which initializes help. When using `redis-cli help xxx` or `redis-cli help ? xxx`, we can't match the command due to empty `helpEntries`, so we output an empty newline. In this commit, we will call `cliInitHelp` to init the help. Note that in this case, we need to call `cliInitHelp` (COMMAND DOCS) every time, which i think is acceptable. So now the output will look like: ``` [redis]# src/redis-cli help get GET key summary: Get the value of a key since: 1.0.0 group: string [redis]# ``` Fixes #10378 This PR also fix a redis-cli crash when using `--ldb --eval`: ``` [root]# src/redis-cli --ldb --eval test.lua test 1 Lua debugging session started, please use: quit -- End the session. restart -- Restart the script in debug mode again. help -- Show Lua script debugging commands. * Stopped at 1, stop reason = step over -> 1 local num = redis.call('GET', KEYS[1]); redis-cli: redis-cli.c:718: cliCountCommands: Assertion `commandTable->element[i]->type == 1' failed. Aborted ``` Because in ldb mode, `COMMAND DOCS` or `COMMAND` will return an array, only with one element, and the type is `REDIS_REPLY_STATUS`, the result is `<error> Unknown Redis Lua debugger command or wrong number of arguments`. So if we are in the ldb mode, and init the Redis HELP, we will get the wrong response and crash the redis-cli. In ldb mode we don't initialize HELP, help is only initialized after the lua debugging session ends. It was broken in #10043
This is a followup to #9656 and implements the following step mentioned in that PR:
The last step is needed to add module command and other non-standard commands.
This PR does not change the interactive hinting mechanism, which still uses only the param strings to provide somewhat unreliable and inconsistent command hints (see #8084). That task is left for a future PR.