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

[NEW] How to update Valkey Module args and save the new args in config file when server is running #1079

Open
hwware opened this issue Sep 27, 2024 · 2 comments

Comments

@hwware
Copy link
Member

hwware commented Sep 27, 2024

The problem/use-case that the feature addresses

Before Valkey 7, we have command: MODULE LOAD path [arg [arg ...]]
And in Valkey, a new command is added: MODULE LOADEX path [CONFIG name value [CONFIG name value ...]]
[ARGS args [args ...]]

In the new command MODULE LOADEX, client could add some configurable parameters for this module, and update these parameters through command: config set. And finally, client could save these updated command by config rewrite to config file.

However, whatever the MODULE LOAD command or MODULE LOADEX command, we have no way to update the arg. Some module clients do not want to restart the server to use new arg, they want to dynamic update these args during runtime.

So I would like to open this issue to discuss some options to implement this feature:

option 1: Based on my pr #1041, which update the module->loadmod in codes, and then let client run config rewrite, module unload, module load to implement this feature.

option 2: Based on my pr, create a new command module reload = module unload, module load

option 3: Try to create an interface so that ValkeyModule_OnLoad or similar function could access the new module->loadmod

Alternatives you've considered

Any alternative solutions or features you've considered, including references to existing open and closed feature requests in this repository.

Additional information

Any additional information that is relevant to the feature request.

@zuiderkwast
Copy link
Contributor

Module args are sent to the module's own ValkeyClient_OnLoad function (which is like a main() function) which runs only when the module is loaded. This is the only way the args are passed to a module. Therefore, I think it makes sense that args can only be changed when a module is reloaded.

Is it a problem to do MODULE UNLOAD followed by MODULE LOAD, because it is not atomic? Is there is a risk that some user sends a command between these two? If yes, then I prefer option 2, MODULE RELOAD. Maybe we need two variants, just like for MODULE LOAD and LOADEX:

MODULE RELOAD [args...]
MODULE RELOADEX [CONFIG name value [...]] [ARGS args...]

@enjoy-binbin
Copy link
Member

enjoy-binbin commented Sep 28, 2024

cant we execute module unload + module load in a multi?

Some module clients do not want to restart the server to use new arg, they want to dynamic update these args during runtime.

can you give more info (or an example) about this? In which cases the module neet to update the args?

@madolson madolson linked a pull request Sep 29, 2024 that will close this issue
15 tasks
@madolson madolson removed a link to a pull request Sep 29, 2024
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants