Unverified Commit 44859a41 authored by DarrenJiang13's avatar DarrenJiang13 Committed by GitHub
Browse files

fix the client type in trackingInvalidateKey() (#11052)

Fix bug with scripts ignoring client tracking NOLOOP and
send an invalidation message anyway.
parent 91c3c742
...@@ -388,7 +388,7 @@ void trackingInvalidateKey(client *c, robj *keyobj, int bcast) { ...@@ -388,7 +388,7 @@ void trackingInvalidateKey(client *c, robj *keyobj, int bcast) {
/* If the client enabled the NOLOOP mode, don't send notifications /* If the client enabled the NOLOOP mode, don't send notifications
* about keys changed by the client itself. */ * about keys changed by the client itself. */
if (target->flags & CLIENT_TRACKING_NOLOOP && if (target->flags & CLIENT_TRACKING_NOLOOP &&
target == c) target == server.current_client)
{ {
continue; continue;
} }
......
...@@ -208,6 +208,19 @@ start_server {tags {"tracking network"}} { ...@@ -208,6 +208,19 @@ start_server {tags {"tracking network"}} {
assert {$res eq {key1}} assert {$res eq {key1}}
} }
test {Invalid keys should not be tracked for scripts in NOLOOP mode} {
$rd_sg CLIENT TRACKING off
$rd_sg CLIENT TRACKING on NOLOOP
$rd_sg HELLO 3
$rd_sg SET key1 1
assert_equal "1" [$rd_sg GET key1]
# For write command in script, invalid key should not be tracked with NOLOOP flag
$rd_sg eval "return redis.call('set', 'key1', '2')" 1 key1
assert_equal "2" [$rd_sg GET key1]
$rd_sg CLIENT TRACKING off
}
test {Tracking only occurs for scripts when a command calls a read-only command} { test {Tracking only occurs for scripts when a command calls a read-only command} {
r CLIENT TRACKING off r CLIENT TRACKING off
r CLIENT TRACKING on r CLIENT TRACKING on
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment