From 99aebb35b06bf32d11bdf143fa5c1fdf6454740e Mon Sep 17 00:00:00 2001 From: Uri Yagelnik Date: Sun, 13 Jul 2025 14:00:07 +0000 Subject: [PATCH 1/2] Fix missing check for executing client Signed-off-by: Uri Yagelnik --- src/db.c | 2 +- tests/unit/type/list.tcl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index b98fba28167..2bbf3062a5b 100644 --- a/src/db.c +++ b/src/db.c @@ -126,7 +126,7 @@ robj *lookupKey(serverDb *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->flag.no_touch && - server.executing_client->cmd->proc != touchCommand) + server.executing_client && server.executing_client->cmd->proc != touchCommand) flags |= LOOKUP_NOTOUCH; if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)) { /* Shared objects can't be stored in the database. */ diff --git a/tests/unit/type/list.tcl b/tests/unit/type/list.tcl index 3382cc611cd..faeb8e1675b 100644 --- a/tests/unit/type/list.tcl +++ b/tests/unit/type/list.tcl @@ -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 From 803c18f024bf07d8184e7e97d460dc3ef06692dc Mon Sep 17 00:00:00 2001 From: Ran Shidlansik Date: Wed, 6 Aug 2025 16:25:14 +0300 Subject: [PATCH 2/2] Update src/db.c Signed-off-by: Ran Shidlansik --- src/db.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index a2ff5d08482..192f22e9799 100644 --- a/src/db.c +++ b/src/db.c @@ -115,7 +115,8 @@ 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 && + if ((flags & LOOKUP_NOTOUCH) == 0 && + server.current_client && server.current_client->flag.no_touch && server.executing_client && server.executing_client->cmd->proc != touchCommand) flags |= LOOKUP_NOTOUCH; if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)) {