do not exit in gen_write_load

This commit is contained in:
Vitah Lin 2026-04-13 16:42:11 +08:00
parent 7ae28b29f6
commit bf22e8c2fd
3 changed files with 18 additions and 11 deletions

View file

@ -18,9 +18,8 @@ set ::tlsdir "tests/tls"
# Continuously sends SET commands to the server. If key is omitted, a random key
# is used for every SET command. The value is always random.
#
# cluster_load (default 0): when 1, exit 0 on MOVED or ASK while draining pipelined
# SET replies; the final drain uses catch so read errors there do not fail shutdown.
# cluster_load (default 0): when 1, MOVED/ASK replies are tolerated while
# draining pipelined responses.
proc gen_write_load {host port seconds tls {key ""} {size 0} {sleep 0} {cluster_load 0}} {
set start_time [clock seconds]
set r [redis $host $port 1 $tls]
@ -54,7 +53,7 @@ proc gen_write_load {host port seconds tls {key ""} {size 0} {sleep 0} {cluster_
if {$cluster_load == 1} {
if {[catch {$r read} err]} {
if {[string match {MOVED*} $err] || [string match {ASK*} $err]} {
exit 0
continue
}
error $err
}
@ -76,7 +75,12 @@ proc gen_write_load {host port seconds tls {key ""} {size 0} {sleep 0} {cluster_
# Read remaining replies
for {set i 0} {$i < $count} {incr i} {
if {$cluster_load == 1} {
catch {$r read}
if {[catch {$r read} err]} {
if {[string match {MOVED*} $err] || [string match {ASK*} $err]} {
continue
}
error $err
}
} else {
$r read
}
@ -84,4 +88,8 @@ proc gen_write_load {host port seconds tls {key ""} {size 0} {sleep 0} {cluster_
exit 0
}
gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] [lindex $argv 5] [lindex $argv 6] [lindex $argv 7]
set cluster_load 0
if {[llength $argv] > 7} {
set cluster_load [lindex $argv 7]
}
gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] [lindex $argv 5] [lindex $argv 6] $cluster_load

View file

@ -604,9 +604,8 @@ proc find_valgrind_errors {stderr on_termination} {
# Execute a background process writing random data for the specified number
# of seconds to the specified Redis instance. If key is omitted, a random key
# is used for every SET command.
#
# cluster_load (default 0): set 1 when cluster slot migration may hit the load
# connection with MOVED/ASK; passed as the last argv to tests/helpers/gen_write_load.tcl.
# cluster_load (default 0): set 1 in cluster slot-migration tests to tolerate
# MOVED/ASK replies while draining pipelined writes in the load helper.
proc start_write_load {host port seconds {key ""} {size 0} {sleep 0} {cluster_load 0}} {
set tclsh [info nameofexecutable]
exec $tclsh tests/helpers/gen_write_load.tcl $host $port $seconds $::tls $key $size $sleep $cluster_load &

View file

@ -810,8 +810,8 @@ start_cluster 3 3 {tags {external:skip cluster} overrides {cluster-node-timeout
# we set a delay to write incremental data
R 1 config set rdb-key-save-delay 1000000
# Start the slot 0 write load on R1. cluster_load 1: R0 imports slot 0 while
# load runs; pipelined reads on this fixed connection may see MOVED/ASK.
# Start slot 0 write load on R1. cluster_load=1 tolerates MOVED/ASK
# replies that can appear while slot 0 is being migrated.
set load_handle [start_write_load "127.0.0.1" [get_port 1] 100 $slot0_key 0 0 1]
# Clear all fail points