From b33a405bf16cfa147f1736a6a3cd64c2fd2b3f7d Mon Sep 17 00:00:00 2001 From: "debing.sun" Date: Sun, 13 Apr 2025 20:32:16 +0800 Subject: [PATCH] Fix timing issue in lazyfree test (#13926) This test was introduced by https://github.com/redis/redis/issues/13853 We determine if the client is in blocked status, but if async flushdb is completed before checking the blocked status, the test will fail. So modify the test to only determine if `lazyfree_pending_objects` is correct to ensure that flushdb is async, that is, the client must be blocked. --- tests/unit/lazyfree.tcl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit/lazyfree.tcl b/tests/unit/lazyfree.tcl index b4650a500..2e60355b8 100644 --- a/tests/unit/lazyfree.tcl +++ b/tests/unit/lazyfree.tcl @@ -176,11 +176,20 @@ start_server {tags {"lazyfree"}} { } test "Unblocks client blocked on lazyfree via REPLICAOF command" { + r config resetstat set rd [redis_deferring_client] populate 50000 ;# Just to make flushdb async slower $rd flushdb - wait_for_blocked_client + + # Verify flushdb run as lazyfree + wait_for_condition 50 100 { + [s lazyfree_pending_objects] > 0 || + [s lazyfreed_objects] > 0 + } else { + fail "FLUSHDB didn't run as lazyfree" + } + # Test that slaveof command unblocks clients without assertion failure r slaveof 127.0.0.1 0 assert_equal [$rd read] {OK}