Skip to content

Commit

Permalink
RED-129256, Fix TOUCH command from script in no-touch mode
Browse files Browse the repository at this point in the history
Command proc should be matched to the executing client, not the current
client.

Co-authored-by: Udi Ron <udi@speedb.io>
  • Loading branch information
oranagra and udi-speedb committed Sep 3, 2024
1 parent 00a8e72 commit a0315d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ robj *lookupKey(redisDb *db, robj *key, int flags) {
* Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */
if (server.current_client && server.current_client->flags & CLIENT_NO_TOUCH &&
server.current_client->cmd->proc != touchCommand)
server.executing_client->cmd->proc != touchCommand)
flags |= LOOKUP_NOTOUCH;
if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)){
if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) {
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/introspection-2.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ start_server {tags {"introspection"}} {
assert_morethan $newlru $oldlru
} {} {needs:debug}

test {Operations in no-touch mode TOUCH alters the last access time of a key} {
r set foo bar
r client no-touch on
set oldlru [getlru foo]
after 1100
r touch foo
set newlru [getlru foo]
assert_morethan $newlru $oldlru
} {} {needs:debug}

test {Operations in no-touch mode TOUCH from script alters the last access time of a key} {
r set foo bar
r client no-touch on
set oldlru [getlru foo]
after 1100
assert_equal {1} [r eval "return redis.call('touch', 'foo')" 0]
set newlru [getlru foo]
assert_morethan $newlru $oldlru
} {} {needs:debug}

test {TOUCH returns the number of existing keys specified} {
r flushdb
r set key1{t} 1
Expand Down

0 comments on commit a0315d9

Please sign in to comment.