summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrenJiang13 <yjjiang1996@163.com>2022-08-10 16:58:54 +0800
committerOran Agra <oran@redislabs.com>2022-12-12 17:02:54 +0200
commitec5564a4cf0e6037f9db5f28cc10377b4370ba07 (patch)
tree365fae6db24c7908480ce2dc5a3df852c65aa518
parent2cd5f6f3ff9ad607164a65c08b247c7485e49968 (diff)
downloadredis-ec5564a4cf0e6037f9db5f28cc10377b4370ba07.tar.gz
fix the client type in trackingInvalidateKey() (#11052)
Fix bug with scripts ignoring client tracking NOLOOP and send an invalidation message anyway. (cherry picked from commit 44859a41ee63b52632f0726d7bf1e6ca1ce47f83)
-rw-r--r--src/tracking.c2
-rw-r--r--tests/unit/tracking.tcl13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/tracking.c b/src/tracking.c
index 32a4c6abc..1584bdbce 100644
--- a/src/tracking.c
+++ b/src/tracking.c
@@ -381,7 +381,7 @@ void trackingInvalidateKey(client *c, robj *keyobj, int bcast) {
/* If the client enabled the NOLOOP mode, don't send notifications
* about keys changed by the client itself. */
if (target->flags & CLIENT_TRACKING_NOLOOP &&
- target == c)
+ target == server.current_client)
{
continue;
}
diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl
index 5a4415856..c1d43614f 100644
--- a/tests/unit/tracking.tcl
+++ b/tests/unit/tracking.tcl
@@ -208,6 +208,19 @@ start_server {tags {"tracking network"}} {
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 {RESP3 Client gets tracking-redir-broken push message after cached key changed when rediretion client is terminated} {
r CLIENT TRACKING on REDIRECT $redir_id
$rd_sg SET key1 1