summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuang Zhw <huang_zhw@126.com>2022-07-31 21:14:39 +0800
committerOran Agra <oran@redislabs.com>2022-12-12 17:02:54 +0200
commit2cd5f6f3ff9ad607164a65c08b247c7485e49968 (patch)
treed36b1da4ce2fa5f8096419e7a04352392a4d3ca4
parentfbcd591b28a479bd790363dbcaca285fbc3015c6 (diff)
downloadredis-2cd5f6f3ff9ad607164a65c08b247c7485e49968.tar.gz
tracking pending invalidation message of flushdb sent by (#11068)
trackingHandlePendingKeyInvalidations should use proto. (cherry picked from commit 61451b02cb3dd5f274a2f5fe72bf0b80b02a744e)
-rw-r--r--src/tracking.c16
-rw-r--r--tests/unit/tracking.tcl2
2 files changed, 12 insertions, 6 deletions
diff --git a/src/tracking.c b/src/tracking.c
index c4dbf82c0..32a4c6abc 100644
--- a/src/tracking.c
+++ b/src/tracking.c
@@ -416,9 +416,15 @@ void trackingHandlePendingKeyInvalidations() {
robj *key = listNodeValue(ln);
/* current_client maybe freed, so we need to send invalidation
* message only when current_client is still alive */
- if (server.current_client != NULL)
- sendTrackingMessage(server.current_client,(char *)key->ptr,sdslen(key->ptr),0);
- decrRefCount(key);
+ if (server.current_client != NULL) {
+ if (key != NULL) {
+ sendTrackingMessage(server.current_client,(char *)key->ptr,sdslen(key->ptr),0);
+ } else {
+ sendTrackingMessage(server.current_client,shared.null[server.current_client->resp]->ptr,
+ sdslen(shared.null[server.current_client->resp]->ptr),1);
+ }
+ }
+ if (key != NULL) decrRefCount(key);
}
listEmpty(server.tracking_pending_keys);
}
@@ -448,8 +454,8 @@ void trackingInvalidateKeysOnFlush(int async) {
client *c = listNodeValue(ln);
if (c->flags & CLIENT_TRACKING) {
if (c == server.current_client) {
- incrRefCount(shared.null[c->resp]);
- listAddNodeTail(server.tracking_pending_keys,shared.null[c->resp]);
+ /* We use a special NULL to indicate that we should send null */
+ listAddNodeTail(server.tracking_pending_keys,NULL);
} else {
sendTrackingMessage(c,shared.null[c->resp]->ptr,sdslen(shared.null[c->resp]->ptr),1);
}
diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl
index a137274c6..5a4415856 100644
--- a/tests/unit/tracking.tcl
+++ b/tests/unit/tracking.tcl
@@ -529,7 +529,7 @@ start_server {tags {"tracking network"}} {
assert_equal $res {OK}
# Consume the invalidate message which is after command response
r read
- } {invalidate *_*}
+ } {invalidate {}}
# Keys are defined to be evicted 100 at a time by default.
# If after eviction the number of keys still surpasses the limit