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

commands in transaction executed not sequently #23

Open
meteorgan opened this issue Feb 27, 2016 · 2 comments
Open

commands in transaction executed not sequently #23

meteorgan opened this issue Feb 27, 2016 · 2 comments

Comments

@meteorgan
Copy link
Contributor

test 1: mget number1 number3 should return 4 15.
redis 127.0.0.1:6370> get number3
"15"
redis 127.0.0.1:6370> multi
OK
redis 127.0.0.1:6370> mget number1 number3
QUEUED
redis 127.0.0.1:6370> set number3 20
QUEUED
redis 127.0.0.1:6370> exec

    1. "4"
    2. "20"
  1. OK

test 2: dbsize in transaction should return 11, not 12.
redis 127.0.0.1:6370> dbsize
(integer) 11
redis 127.0.0.1:6370> multi
OK
redis 127.0.0.1:6370> dbsize
QUEUED
redis 127.0.0.1:6370> set number2 1
QUEUED
redis 127.0.0.1:6370> exec

  1. (integer) 12
  2. OK

the reason is the commands are sent sequently, but not executed sequently.

@stephenmcd
Copy link
Owner

I think a good way to fix this will be to have the MULTI/EXEC list of commands get put inside a simple Lua script that we can generate when EXEC is called. The Lua script will just call redis.call sequentially and build a list (Lua table) of responses. If we do this, I think will simplify a lot of the current code around transactions since in Scala we only ever deal with one command being run (EVAL/EVVALSHA).

What do you think? The other option is to rewrite the current transaction code to go from "send commands -> await all replies" to "send command -> await reply -> send command -> await reply -> etc".

There might be some overhead compiling/running the Lua script, but it will simplify the code a lot.

@meteorgan
Copy link
Contributor Author

I don't know much about Lua script, i will look at it later. In your second solution, your don't need to send all commands sequently, the problem is commands with multi key and some commands like dbsize executed by clientNode may conflict with other commands, but implementing this is more complicated.

And there are other problems about the transaction, i will post it later.

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

2 participants