From e029dd7a17de5797531e961ba14db87fe950788c Mon Sep 17 00:00:00 2001 From: Vitah Lin Date: Wed, 27 May 2026 20:37:35 +0800 Subject: [PATCH] fx --- tests/unit/moduleapi/datatype.tcl | 35 +++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/tests/unit/moduleapi/datatype.tcl b/tests/unit/moduleapi/datatype.tcl index fffb84145..a61e04f5b 100644 --- a/tests/unit/moduleapi/datatype.tcl +++ b/tests/unit/moduleapi/datatype.tcl @@ -151,8 +151,22 @@ start_server {tags {"modules external:skip"}} { set n 20000 set dummy "[string repeat x 400]" set rd [redis_deferring_client] - for {set i 0} {$i < $n} {incr i} { $rd datatype.set k$i 1 $dummy } - for {set i 0} {$i < [expr $n]} {incr i} { $rd read } ;# Discard replies + + # Use batching to avoid TCP deadlock when deferred replies accumulate. + set batch_size 1000 + for {set i 0} {$i < $n} {incr i} { + $rd datatype.set k$i 1 $dummy + + if {($i + 1) % $batch_size == 0} { + for {set j 0} {$j < $batch_size} {incr j} { + $rd read + } + } + } + set remaining [expr {$n % $batch_size}] + for {set i 0} {$i < $remaining} {incr i} { + $rd read + } after 120 ;# serverCron only updates the info once in 100ms if {$::verbose} { @@ -163,8 +177,21 @@ start_server {tags {"modules external:skip"}} { } assert_lessthan [s allocator_frag_ratio] 1.05 - for {set i 0} {$i < $n} {incr i 2} { $rd del k$i } - for {set j 0} {$j < $n} {incr j 2} { $rd read } ; # Discard del replies + set del_replies 0 + for {set i 0} {$i < $n} {incr i 2} { + $rd del k$i + incr del_replies + + if {$del_replies % $batch_size == 0} { + for {set j 0} {$j < $batch_size} {incr j} { + $rd read + } + } + } + set remaining [expr {$del_replies % $batch_size}] + for {set i 0} {$i < $remaining} {incr i} { + $rd read + } after 120 ;# serverCron only updates the info once in 100ms assert_morethan [s allocator_frag_ratio] 1.4