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

Add new SCRIPT SHOW subcommand to dump script via sha1 #617

Merged
merged 13 commits into from
Jun 19, 2024

Conversation

kukey
Copy link
Contributor

@kukey kukey commented Jun 10, 2024

In some scenarios, the business may not be able to find the
previously used Lua script and only have a SHA signature.
Or there are multiple identical evalsha's args in monitor/slowlog,
and admin is not able to distinguish the script body.

Add a new script subcommmand to show the contents of script
given the scripts sha1. Returns a NOSCRIPT error if the script
is not present in the cache.

Usage: SCRIPT SHOW sha1
Complexity: O(1)

Closes #604.
Doc PR: valkey-io/valkey-doc#143

@kukey kukey force-pushed the script-add-dump-subcommand branch 2 times, most recently from 10ff79a to f22bd20 Compare June 10, 2024 05:51
src/eval.c Outdated Show resolved Hide resolved
src/eval.c Outdated Show resolved Hide resolved
src/commands/script-dump.json Outdated Show resolved Hide resolved
src/commands/script-dump.json Outdated Show resolved Hide resolved
@madolson madolson added release-notes This issue should get a line item in the release notes major-decision-pending Major decision pending by TSC team labels Jun 10, 2024
@madolson madolson linked an issue Jun 10, 2024 that may be closed by this pull request
@kukey kukey force-pushed the script-add-dump-subcommand branch from 3015661 to 3e0939c Compare June 11, 2024 00:15
src/eval.c Outdated Show resolved Hide resolved
src/eval.c Outdated Show resolved Hide resolved
Copy link
Member

@enjoy-binbin enjoy-binbin left a comment

Choose a reason for hiding this comment

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

please also update the top comment instead of directly linking to an issue

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 70.02%. Comparing base (71dd85d) to head (e8c0d1f).
Report is 23 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #617      +/-   ##
============================================
- Coverage     70.09%   70.02%   -0.07%     
============================================
  Files           110      110              
  Lines         60041    60076      +35     
============================================
- Hits          42085    42068      -17     
- Misses        17956    18008      +52     
Files Coverage Δ
src/commands.def 100.00% <ø> (ø)
src/server.c 88.54% <100.00%> (-0.39%) ⬇️
src/eval.c 56.60% <75.00%> (+0.53%) ⬆️

... and 32 files with indirect coverage changes

@kukey kukey force-pushed the script-add-dump-subcommand branch from 5d58999 to ab9847e Compare June 11, 2024 05:16
@madolson
Copy link
Member

@valkey-io/core-team Vote on adding this new command which allows dumping a specific command. There is still some minor open comment about error wording, but other than that it is broadly updated.

@madolson
Copy link
Member

@kukey Btw, you need to regenerate the commands.def and check it in.

Copy link
Member

@madolson madolson left a comment

Choose a reason for hiding this comment

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

Looks OK to me. Waiting on other for core team approval before merging.

@madolson madolson added the needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. label Jun 12, 2024
@madolson
Copy link
Member

Once we have directional approval for the merge, please create a PR to the doc repo similar to https://github.com/valkey-io/valkey-doc/blob/main/commands/script-exists.md.

src/commands/script-dump.json Outdated Show resolved Hide resolved
src/eval.c Show resolved Hide resolved
@enjoy-binbin enjoy-binbin changed the title script add dump subcommand Add new SCRIPT DUMP subcommand to dump script via sha1 Jun 13, 2024
@enjoy-binbin
Copy link
Member

@valkey-io/core-team I think this one is ready to merge, i updated the top comment, please take a look.

@soloestoy
Copy link
Member

I like this idea, this can help users to debug. But the subcommand's name SCRIPT DUMP is a bit wired to me, since other commands like DUMP and FUNCTION DUMP's reply is rdb format, but this subcommand's reply is just raw. Maybe SCRIPT GET or SCRIPT FETCH is better.

@madolson
Copy link
Member

madolson commented Jun 14, 2024

I like this idea, this can help users to debug. But the subcommand's name SCRIPT DUMP is a bit wired to me, since other commands like DUMP and FUNCTION DUMP's reply is rdb format, but this subcommand's reply is just raw. Maybe SCRIPT GET or SCRIPT FETCH is better.

I don't feel strongly. SCRIPT GET would be my preferred option of the two. I guess I would prefer something like SCRIPT DISPLAY.

@zuiderkwast
Copy link
Contributor

Regarding subcommand name, how about SCRIPT SHOW?

Compare: In MySQL it's possible to get the CREATE TABLE command for a table using SHOW CREATE TABLE mytable.

@madolson
Copy link
Member

Regarding subcommand name, how about SCRIPT SHOW?

I considered that but it just sort of sounds weird to me, but I would prefer that over SCRIPT GET and SCRIPT FETCH.

src/eval.c Show resolved Hide resolved
@hwware
Copy link
Member

hwware commented Jun 14, 2024

Regarding subcommand name, how about SCRIPT SHOW?

I considered that but it just sort of sounds weird to me, but I would prefer that over SCRIPT GET and SCRIPT FETCH.

script fetch is much more officially.

@zuiderkwast
Copy link
Contributor

Fetch sounds like "go and get it from somewhere", like from another node or file or something. Another idea: SCRIPT SOURCE.

Change-Id: I60aacd3198652174883f335b36efc18d69a1fb43
Signed-off-by: wei.kukey <[email protected]>
@kukey
Copy link
Contributor Author

kukey commented Jun 16, 2024

Once we have directional approval for the merge, please create a PR to the doc repo similar to https://github.com/valkey-io/valkey-doc/blob/main/commands/script-exists.md.

@madolson valkey-io/valkey-doc#143

@kukey
Copy link
Contributor Author

kukey commented Jun 16, 2024

I prefer SCRIPT GET, it's clear and simple. @valkey-io/core-team which subcommand we select? Or also continue use SCRIPT DUMP

@PingXie
Copy link
Member

PingXie commented Jun 16, 2024

Regarding subcommand name, how about SCRIPT SHOW?

my vote ^

@madolson
Copy link
Member

@kukey We have an online syncup tomorrow, I think we can quickly get consensus since people's opinions seem all over the place online.

@madolson
Copy link
Member

@kukey SCRIPT SHOW Seems to be the winner from our online discussion.

@madolson madolson added major-decision-approved Major decision approved by TSC team and removed major-decision-pending Major decision pending by TSC team needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. labels Jun 17, 2024
@kukey kukey changed the title Add new SCRIPT DUMP subcommand to dump script via sha1 Add new SCRIPT SHOW subcommand to dump script via sha1 Jun 18, 2024
@kukey
Copy link
Contributor Author

kukey commented Jun 18, 2024

@kukey SCRIPT SHOW Seems to be the winner from our online discussion.

copy

Change-Id: Ieb1b35629728b269c270ea97d775b4c2542a755f
Signed-off-by: wei.kukey <[email protected]>
src/commands/script-show.json Outdated Show resolved Hide resolved
src/commands/script-show.json Outdated Show resolved Hide resolved
@zuiderkwast zuiderkwast added the needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. label Jun 18, 2024
@madolson
Copy link
Member

madolson commented Jun 18, 2024

@zuiderkwast I've been using the needs-doc-pr to just track if it's been opened. The doc PR already exists here: valkey-io/valkey-doc#143. Is this inline with what you were thinking?

@zuiderkwast
Copy link
Contributor

OK, sounds good. I didn't notice we remove it before. In redis it was never removed I think.

I missed the link to the doc PR. Can we add the link in the PR description to make it more visible?

@zuiderkwast zuiderkwast removed the needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. label Jun 18, 2024
Signed-off-by: Madelyn Olson <[email protected]>

Co-authored-by: Viktor Söderqvist <[email protected]>
src/commands.def Outdated Show resolved Hide resolved
Signed-off-by: Madelyn Olson <[email protected]>
@madolson madolson merged commit ae2d421 into valkey-io:unstable Jun 19, 2024
20 checks passed
@kukey kukey deleted the script-add-dump-subcommand branch June 19, 2024 13:16
madolson added a commit to valkey-io/valkey-doc that referenced this pull request Jul 14, 2024
Docs for valkey-io/valkey#617

Change-Id: I9213aa113bcbf1337ac25e8f0540155e25eb1d05

---------

Signed-off-by: wei.kukey <[email protected]>
Signed-off-by: kukey <[email protected]>
Signed-off-by: Madelyn Olson <[email protected]>
Co-authored-by: Madelyn Olson <[email protected]>
Co-authored-by: Wen Hui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-decision-approved Major decision approved by TSC team release-notes This issue should get a line item in the release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

script add dump sub command
7 participants