Skip to content

scripting: flag lua_client as CLIENT_MULTI after redis.replicate_command() immediately#5780

Merged
antirez merged 2 commits intoredis:unstablefrom
soloestoy:lua-multi-more-clear
Dec 19, 2019
Merged

scripting: flag lua_client as CLIENT_MULTI after redis.replicate_command() immediately#5780
antirez merged 2 commits intoredis:unstablefrom
soloestoy:lua-multi-more-clear

Conversation

@soloestoy
Copy link
Contributor

Hi @antirez and @yossigo , we have talked about this in #5323, I think we should discuss it deeply now.

To avoid nested MULTI/EXEC in PR #4467, we check the lua_caller's flag, if we are in the MULTI context we flag the lua_client as CLIENT_MULTI.

But it's not enough, we shoud flag lua_client as CLIENT_MULTI after redis.replicate_commands() immediately, or the first write command after redis.replicate_commands() cannot know it's in an transaction.

I know the missing CLIENT_MULTI doesn't have any effect now, but it's a real bug and we should fix it, in case someday we allow some dangerous command like BLPOP.

Moreover, reflect MULTI state in every luaRedisGenericCommand() is not clear and not easy to understand, I think we can change lua_client's flag in a more explicit way, like in evalGenericCommand().

@yossigo
Copy link
Collaborator

yossigo commented Jan 16, 2019

Hi @soloestoy, this makes sense to me and I think it's cleaner this way indeed.

…ands() immediately

To avoid nested MULTI/EXEC, we check the lua_caller's flag,
if we are in the MULTI context we flag the lua_client as
CLIENT_MULTI, but it's not enough we shoud flag lua_client
as CLIENT_MULTI after redis.replicate_commands() immediately
or the first write command after redis.replicate_commands()
cannot know it's in an transaction, I know the missing CLIENT_MULTI
doesn't have any effect now, but it's a real bug and we should fix
it, in case someday we allow some dangerous command like BLPOP.
Change server.lua_client's flag in a more explicit way.
@soloestoy soloestoy force-pushed the lua-multi-more-clear branch from 2de3949 to 73841e8 Compare November 22, 2019 03:59
@antirez antirez merged commit 9a7b6a9 into redis:unstable Dec 19, 2019
@antirez
Copy link
Contributor

antirez commented Dec 19, 2019

Thanks, merged.

JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Dec 24, 2019
scripting: flag lua_client as CLIENT_MULTI after redis.replicate_command() immediately
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 this pull request may close these issues.

3 participants