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.
This commit is contained in:
debing.sun 2025-04-13 20:32:16 +08:00 committed by GitHub
parent 90fa80f372
commit b33a405bf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -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}