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

Support Redis >= 6.2.7 (Lua readonly global tables) #268

Closed
nsaje opened this issue Mar 14, 2023 · 3 comments · Fixed by #284
Closed

Support Redis >= 6.2.7 (Lua readonly global tables) #268

nsaje opened this issue Mar 14, 2023 · 3 comments · Fixed by #284

Comments

@nsaje
Copy link
Contributor

nsaje commented Mar 14, 2023

On redis >= 6.2.7 we currently encounter an "Attempt to modify a readonly table" error (more info here)
This error is introduced by redis/redis#10651 which hardened Lua script execution by not allowing modifications of global tables and is affecting Redis versions >= 6.2.7.

It happens because when trying to execute a pipeline using the execute_pipeline Lua script, we try to set the KEYS and ARGV global variables before calling another script using EVALSHA.

Executing pipelines via a Lua script was introduced because Redis transactions don't abort execution of commands when one of the commands in the transaction fails.

The fix would probably be to use Redis functions for Redis 7.0 and above, because they're directly callable by providing keys and argv in the call itself using FCALL <func_name> <keys> <argv>

@nsaje
Copy link
Contributor Author

nsaje commented Mar 14, 2023

cc @thomasst , any thoughts on this? 😄

@thomasst
Copy link
Member

The fix would probably be to use Redis functions for Redis 7.0 and above, because they're directly callable by providing keys and argv in the call itself using FCALL <func_name> <keys> <argv>

I have not played around with Redis 7 but that looks good. The way we're doing it currently is a hack.

@joeleclems
Copy link

joeleclems commented May 23, 2023

``Hi,
For information, we encountered the same problem with redis 6.2.6. We also have redis databases in version 6.2.5, and no problems with theses databases.
So i think the problem is on redis >= 6.2.6

Code that create problem for us is :

string.startswith = function(self, str) 
    return self:find('^' .. str) ~= nil
end

And we solved it by creating our own function (no so good... but it works)

local function string_start_with(str, startwith)
    return string.find(str,'^' .. startwith) ~= nil
end

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

Successfully merging a pull request may close this issue.

3 participants