Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ robj *lookupKey(serverDb *db, robj *key, int flags) {
/* Update the access time for the ageing algorithm.
* 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->flag.no_touch && server.executing_client &&
server.executing_client->cmd->proc != touchCommand)
if ((flags & LOOKUP_NOTOUCH) == 0 &&
server.current_client && server.current_client->flag.no_touch &&
server.executing_client && server.executing_client->cmd->proc != touchCommand)
Comment thread
enjoy-binbin marked this conversation as resolved.
flags |= LOOKUP_NOTOUCH;
if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)) {
/* Shared objects can't be stored in the database. */
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/type/list.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2453,4 +2453,36 @@ foreach {pop} {BLPOP BLMPOP_RIGHT} {
$rd close
}

test "CLIENT NO-TOUCH with BRPOP and RPUSH regression test" {
# Test scenario:
# 1. Client 1: CLIENT NO-TOUCH on
# 2. Client 2: BRPOP mylist 0
# 3. Client 1: RPUSH mylist elem

# cleanup first
r del mylist

# Create two test clients
set rd1 [valkey_deferring_client]
set rd2 [valkey_deferring_client]

# Client 1: Enable CLIENT NO-TOUCH
$rd1 client no-touch on
assert_equal {OK} [$rd1 read]

# Client 2: Block waiting for elements in mylist
$rd2 brpop mylist 0
wait_for_blocked_client

# Client 1: Push an element to mylist
$rd1 rpush mylist elem
assert_equal {1} [$rd1 read]

# Verify Client 2 received the element
assert_equal {mylist elem} [$rd2 read]

$rd1 close
$rd2 close
}

} ;# stop servers
Loading