Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When client tracking is on, invalidation message of flushdb in a transaction #11038

Merged
merged 1 commit into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/tracking.c
Expand Up @@ -454,7 +454,12 @@ void trackingInvalidateKeysOnFlush(int async) {
while ((ln = listNext(&li)) != NULL) {
client *c = listNodeValue(ln);
if (c->flags & CLIENT_TRACKING) {
sendTrackingMessage(c,shared.null[c->resp]->ptr,sdslen(shared.null[c->resp]->ptr),1);
if (c == server.current_client) {
incrRefCount(shared.null[c->resp]);
listAddNodeTail(server.tracking_pending_keys,shared.null[c->resp]);
} else {
sendTrackingMessage(c,shared.null[c->resp]->ptr,sdslen(shared.null[c->resp]->ptr),1);
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/tracking.tcl
Expand Up @@ -548,6 +548,20 @@ start_server {tags {"tracking network"}} {
assert_equal [lindex [$rd_redirection read] 2] {}
}

test {flushdb tracking invalidation message is not interleaved with transaction response} {
clean_all
r HELLO 3
r CLIENT TRACKING on
r SET a{t} 1
r GET a{t}
r MULTI
r FLUSHDB
set res [r EXEC]
assert_equal $res {OK}
# Consume the invalidate message which is after command response
r read
} {invalidate *_*}

# Keys are defined to be evicted 100 at a time by default.
# If after eviction the number of keys still surpasses the limit
# defined in tracking-table-max-keys, we increases eviction
Expand Down