Describe the bug
By reading the code of smovecommand in src/t_set.c(line 395), I find the func will signal its dstkey modified before change it in setTypeAdd() (line 399).
To reproduce
Just run a redis server and use two clients to do the commands as follow:
A> sadd a 1 (integer) 1 A> sadd b 1 (integer) 1 A> WATCH a OK A> MULTI OK A> sadd a 2 QUEUE B> smove b a 1 (it singal a is modified while a is not!) (integer) 1 A> EXEC (nil) A> smembers a "1"
As a constract, if the client B use "sadd a 1" command, which does not change a, the transaction of A will not abort.
Expected behavior
If the a is not modified, it should not be signaled modified. Just like this.
A> sadd a 1 (integer) 1 A> sadd b 1 (integer) 1 A> WATCH a OK A> MULTI OK A> sadd a 2 QUEUE B> smove b a 1 (it should not singal a is modified while a is not) (integer) 1 A> EXEC (integer) 1 A> smembers a "1" "2"
Additional information
nothing. It's just a little and esay bug.
GOOD LUCK!
Comment From: enjoy-binbin
Good catch. Seem you are right. Although I haven't read it carefully