SMOVE only notify dstset when the addition is successful. (#9244)
in case dest key already contains the member, the dest key isn't modified, so the command shouldn't invalidate watch. (cherry picked from commit 11dc4e59b365d6cd8699604d7d1c1025b6bb6259)
This commit is contained in:
parent
4edf50d8e2
commit
72b8db27c8
@ -392,12 +392,12 @@ void smoveCommand(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
signalModifiedKey(c,c->db,c->argv[1]);
|
signalModifiedKey(c,c->db,c->argv[1]);
|
||||||
signalModifiedKey(c,c->db,c->argv[2]);
|
|
||||||
server.dirty++;
|
server.dirty++;
|
||||||
|
|
||||||
/* An extra key has changed when ele was successfully added to dstset */
|
/* An extra key has changed when ele was successfully added to dstset */
|
||||||
if (setTypeAdd(dstset,ele->ptr)) {
|
if (setTypeAdd(dstset,ele->ptr)) {
|
||||||
server.dirty++;
|
server.dirty++;
|
||||||
|
signalModifiedKey(c,c->db,c->argv[2]);
|
||||||
notifyKeyspaceEvent(NOTIFY_SET,"sadd",c->argv[2],c->db->id);
|
notifyKeyspaceEvent(NOTIFY_SET,"sadd",c->argv[2],c->db->id);
|
||||||
}
|
}
|
||||||
addReply(c,shared.cone);
|
addReply(c,shared.cone);
|
||||||
|
@ -826,6 +826,28 @@ start_server {
|
|||||||
lsort [r smembers set]
|
lsort [r smembers set]
|
||||||
} {a b c}
|
} {a b c}
|
||||||
|
|
||||||
|
test "SMOVE only notify dstset when the addition is successful" {
|
||||||
|
r del srcset{t}
|
||||||
|
r del dstset{t}
|
||||||
|
|
||||||
|
r sadd srcset{t} a b
|
||||||
|
r sadd dstset{t} a
|
||||||
|
|
||||||
|
r watch dstset{t}
|
||||||
|
|
||||||
|
r multi
|
||||||
|
r sadd dstset{t} c
|
||||||
|
|
||||||
|
set r2 [redis_client]
|
||||||
|
$r2 smove srcset{t} dstset{t} a
|
||||||
|
|
||||||
|
# The dstset is actually unchanged, multi should success
|
||||||
|
r exec
|
||||||
|
set res [r scard dstset{t}]
|
||||||
|
assert_equal $res 2
|
||||||
|
$r2 close
|
||||||
|
}
|
||||||
|
|
||||||
tags {slow} {
|
tags {slow} {
|
||||||
test {intsets implementation stress testing} {
|
test {intsets implementation stress testing} {
|
||||||
for {set j 0} {$j < 20} {incr j} {
|
for {set j 0} {$j < 20} {incr j} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user