diff --git a/runtest b/runtest index 88617c1a63f..09b9d491b56 100755 --- a/runtest +++ b/runtest @@ -1,5 +1,5 @@ #!/bin/sh -TCL_VERSIONS="8.5 8.6 8.7" +TCL_VERSIONS="8.5 8.6 8.7 9.0" TCLSH="" for VERSION in $TCL_VERSIONS; do diff --git a/runtest-cluster b/runtest-cluster index e465ce1863f..b7e68fb65c8 100755 --- a/runtest-cluster +++ b/runtest-cluster @@ -1,5 +1,5 @@ #!/bin/sh -TCL_VERSIONS="8.5 8.6 8.7" +TCL_VERSIONS="8.5 8.6 8.7 9.0" TCLSH="" for VERSION in $TCL_VERSIONS; do diff --git a/runtest-moduleapi b/runtest-moduleapi index ff685afb66c..4a846bf9e76 100755 --- a/runtest-moduleapi +++ b/runtest-moduleapi @@ -1,5 +1,5 @@ #!/bin/sh -TCL_VERSIONS="8.5 8.6 8.7" +TCL_VERSIONS="8.5 8.6 8.7 9.0" TCLSH="" [ -z "$MAKE" ] && MAKE=make diff --git a/runtest-sentinel b/runtest-sentinel index 60d8c3ceaba..82ffce24e13 100755 --- a/runtest-sentinel +++ b/runtest-sentinel @@ -1,5 +1,5 @@ #!/bin/sh -TCL_VERSIONS="8.5 8.6 8.7" +TCL_VERSIONS="8.5 8.6 8.7 9.0" TCLSH="" for VERSION in $TCL_VERSIONS; do diff --git a/src/call_reply.c b/src/call_reply.c index 0afaf4469e3..dec99f203c6 100644 --- a/src/call_reply.c +++ b/src/call_reply.c @@ -554,7 +554,7 @@ CallReply *callReplyCreateError(sds reply, void *private_data) { sdsfree(reply); } list *deferred_error_list = listCreate(); - listSetFreeMethod(deferred_error_list, (void (*)(void*))sdsfree); + listSetFreeMethod(deferred_error_list, sdsfreeVoid); listAddNodeTail(deferred_error_list, sdsnew(err_buff)); return callReplyCreate(err_buff, deferred_error_list, private_data); } diff --git a/src/db.c b/src/db.c index ffeee78e180..5153ccf9649 100644 --- a/src/db.c +++ b/src/db.c @@ -1042,7 +1042,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) { * The exception to the above is ZSET, where we do allocate temporary * strings even when scanning a dict. */ if (o && (!ht || o->type == OBJ_ZSET)) { - listSetFreeMethod(keys, (void (*)(void*))sdsfree); + listSetFreeMethod(keys, sdsfreeVoid); } if (ht) { diff --git a/src/eval.c b/src/eval.c index 162acf90d16..01d7aeb6f27 100644 --- a/src/eval.c +++ b/src/eval.c @@ -684,7 +684,7 @@ void ldbInit(void) { ldb.conn = NULL; ldb.active = 0; ldb.logs = listCreate(); - listSetFreeMethod(ldb.logs,(void (*)(void*))sdsfree); + listSetFreeMethod(ldb.logs,sdsfreeVoid); ldb.children = listCreate(); ldb.src = NULL; ldb.lines = 0; diff --git a/src/functions.c b/src/functions.c index c858db975bf..2fd09ce914a 100644 --- a/src/functions.c +++ b/src/functions.c @@ -167,6 +167,10 @@ static void engineLibraryFree(functionLibInfo* li) { zfree(li); } +static void engineLibraryFreeVoid(void *li) { + engineLibraryFree(li); +} + static void engineLibraryDispose(dict *d, void *obj) { UNUSED(d); engineLibraryFree(obj); @@ -349,7 +353,7 @@ static int libraryJoin(functionsLibCtx *functions_lib_ctx_dst, functionsLibCtx * } else { if (!old_libraries_list) { old_libraries_list = listCreate(); - listSetFreeMethod(old_libraries_list, (void (*)(void*))engineLibraryFree); + listSetFreeMethod(old_libraries_list, engineLibraryFreeVoid); } libraryUnlink(functions_lib_ctx_dst, old_li); listAddNodeTail(old_libraries_list, old_li); diff --git a/src/listpack.c b/src/listpack.c index 70c41f60faa..69c4f27c686 100644 --- a/src/listpack.c +++ b/src/listpack.c @@ -2511,7 +2511,7 @@ int listpackTest(int argc, char *argv[], int flags) { for (i = 0; i < iteration; i++) { lp = lpNew(0); ref = listCreate(); - listSetFreeMethod(ref,(void (*)(void*))sdsfree); + listSetFreeMethod(ref,sdsfreeVoid); len = rand() % 256; /* Create lists */ diff --git a/src/networking.c b/src/networking.c index 76ce72f1a10..eb62ee88a4b 100644 --- a/src/networking.c +++ b/src/networking.c @@ -515,7 +515,7 @@ void afterErrorReply(client *c, const char *s, size_t len, int flags) { if (c->flags & CLIENT_MODULE) { if (!c->deferred_reply_errors) { c->deferred_reply_errors = listCreate(); - listSetFreeMethod(c->deferred_reply_errors, (void (*)(void*))sdsfree); + listSetFreeMethod(c->deferred_reply_errors, sdsfreeVoid); } listAddNodeTail(c->deferred_reply_errors, sdsnewlen(s, len)); return; diff --git a/src/replication.c b/src/replication.c index 2a843f99542..3320cd8e61f 100644 --- a/src/replication.c +++ b/src/replication.c @@ -200,7 +200,7 @@ void rebaseReplicationBuffer(long long base_repl_offset) { void resetReplicationBuffer(void) { server.repl_buffer_mem = 0; server.repl_buffer_blocks = listCreate(); - listSetFreeMethod(server.repl_buffer_blocks, (void (*)(void*))zfree); + listSetFreeMethod(server.repl_buffer_blocks, zfree); } int canFeedReplicaReplBuffer(client *replica) { diff --git a/src/server.c b/src/server.c index 9531fe910d6..75fa0bd0e2c 100644 --- a/src/server.c +++ b/src/server.c @@ -2642,7 +2642,7 @@ void initServer(void) { server.db[j].avg_ttl = 0; server.db[j].defrag_later = listCreate(); server.db[j].slots_to_keys = NULL; /* Set by clusterInit later on if necessary. */ - listSetFreeMethod(server.db[j].defrag_later,(void (*)(void*))sdsfree); + listSetFreeMethod(server.db[j].defrag_later,sdsfreeVoid); } evictionPoolAlloc(); /* Initialize the LRU keys pool. */ server.pubsub_channels = dictCreate(&keylistDictType); diff --git a/src/ziplist.c b/src/ziplist.c index c891625a931..ad5e827f54f 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -2368,7 +2368,7 @@ int ziplistTest(int argc, char **argv, int flags) { for (i = 0; i < iteration; i++) { zl = ziplistNew(); ref = listCreate(); - listSetFreeMethod(ref,(void (*)(void*))sdsfree); + listSetFreeMethod(ref,sdsfreeVoid); len = rand() % 256; /* Create lists */ diff --git a/tests/cluster/tests/17-diskless-load-swapdb.tcl b/tests/cluster/tests/17-diskless-load-swapdb.tcl index 7a56ec783b1..74204013638 100644 --- a/tests/cluster/tests/17-diskless-load-swapdb.tcl +++ b/tests/cluster/tests/17-diskless-load-swapdb.tcl @@ -52,12 +52,13 @@ test "Main db not affected when fail to diskless load" { set num 10000 set value [string repeat A 1024] set rd [redis_deferring_client redis $master_id] + $rd client reply off for {set j 0} {$j < $num} {incr j} { $rd set $j $value + if {$j % 1000 == 0} {$rd flush} } - for {set j 0} {$j < $num} {incr j} { - $rd read - } + $rd client reply on + assert_equal OK [$rd read] # Start the replica again restart_instance redis $replica_id diff --git a/tests/integration/corrupt-dump-fuzzer.tcl b/tests/integration/corrupt-dump-fuzzer.tcl index 9cd4ff913ad..16707cda433 100644 --- a/tests/integration/corrupt-dump-fuzzer.tcl +++ b/tests/integration/corrupt-dump-fuzzer.tcl @@ -13,6 +13,7 @@ if { ! [ catch { proc generate_collections {suffix elements} { set rd [redis_deferring_client] + $rd client reply off for {set j 0} {$j < $elements} {incr j} { # add both string values and integers if {$j % 2 == 0} {set val $j} else {set val "_$j"} @@ -22,9 +23,8 @@ proc generate_collections {suffix elements} { $rd sadd set$suffix $val $rd xadd stream$suffix * item 1 value $val } - for {set j 0} {$j < $elements * 5} {incr j} { - $rd read ; # Discard replies - } + $rd client reply on + assert_equal OK [$rd read] $rd close } diff --git a/tests/integration/failover.tcl b/tests/integration/failover.tcl index 21fa3d2815b..6361c20eda3 100644 --- a/tests/integration/failover.tcl +++ b/tests/integration/failover.tcl @@ -33,6 +33,8 @@ start_server {overrides {save {}}} { $node_2 replicaof $node_0_host $node_0_port wait_for_sync $node_1 wait_for_sync $node_2 + verify_replica_online $node_0 0 50 + verify_replica_online $node_0 1 50 } test {failover command fails with invalid host} { diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index cce21671f89..1790fca8413 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -263,16 +263,15 @@ start_server {overrides {save ""}} { # changing some keys and read the reported COW size, we are using small key size to prevent from # the "dismiss mechanism" free memory and reduce the COW size) set rd [redis_deferring_client 0] + $rd client reply off set size 500 ;# aim for the 512 bin (sds overhead) set cmd_count 10000 + set AAA [string repeat A $size] for {set k 0} {$k < $cmd_count} {incr k} { - $rd set key$k [string repeat A $size] + $rd set key$k $AAA } - - for {set k 0} {$k < $cmd_count} {incr k} { - catch { $rd read } - } - + $rd client reply on + assert_equal OK [$rd read] $rd close # start background rdb save @@ -301,8 +300,9 @@ start_server {overrides {save ""}} { # trigger copy-on-write set modified_keys 16 + set BBB [string repeat B $size] for {set k 0} {$k < $modified_keys} {incr k} { - r setrange key$key_idx 0 [string repeat B $size] + r setrange key$key_idx 0 $BBB incr key_idx 1 } diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 8dacf2ddad7..f4ba208f8ba 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -644,6 +644,7 @@ proc print_help_screen {} { "--timeout Test timeout in seconds (default 20 min)." "--force-failure Force the execution of a test that always fails." "--config Extra config file argument." + "--io-threads Run tests with IO threads enabled." "--skipfile Name of a file containing test names or regexp patterns (if starts with '/') that should be skipped (one per line). This option can be repeated." "--skiptest Test name or regexp pattern (if starts with '/') to skip. This option can be repeated." "--tags Run only tests having specified tags or not having '-' prefixed tags." @@ -688,6 +689,9 @@ for {set j 0} {$j < [llength $argv]} {incr j} { lappend ::global_overrides $arg lappend ::global_overrides $arg2 incr j 2 + } elseif {$opt eq {--io-threads}} { + lappend ::global_overrides "io-threads" "4" + lappend ::global_overrides "io-threads-do-reads" "yes" } elseif {$opt eq {--log-req-res}} { set ::log_req_res 1 } elseif {$opt eq {--force-resp3}} { diff --git a/tests/unit/client-eviction.tcl b/tests/unit/client-eviction.tcl index 789bf997b89..3bef92b690c 100644 --- a/tests/unit/client-eviction.tcl +++ b/tests/unit/client-eviction.tcl @@ -91,17 +91,31 @@ start_server {} { lassign [gen_client] rr cname # Attempt to fill the query buff with only half the percentage threshold verify we're not disconnected set n [expr $maxmemory_clients_actual / 2] - $rr write [join [list "*1\r\n\$$n\r\n" [string repeat v $n]] ""] + # send incomplete command (n - 1) to make sure we don't use the shared qb + $rr write [join [list "*1\r\n\$$n\r\n" [string repeat v [expr {$n - 1}]]] ""] $rr flush + # Wait for the client to start using a private query buffer. + wait_for_condition 10 10 { + [client_field $cname qbuf] > 0 + } else { + fail "client should start using a private query buffer" + } set tot_mem [client_field $cname tot-mem] assert {$tot_mem >= $n && $tot_mem < $maxmemory_clients_actual} # Attempt to fill the query buff with the percentage threshold of maxmemory and verify we're evicted $rr close lassign [gen_client] rr cname + # send incomplete command (maxmemory_clients_actual - 1) to make sure we don't use the shared qb catch { - $rr write [join [list "*1\r\n\$$maxmemory_clients_actual\r\n" [string repeat v $maxmemory_clients_actual]] ""] + $rr write [join [list "*1\r\n\$$maxmemory_clients_actual\r\n" [string repeat v [expr {$maxmemory_clients_actual - 1}]]] ""] $rr flush + # Wait for the client to start using a private query buffer. + wait_for_condition 10 10 { + [client_field $cname qbuf] > 0 + } else { + fail "client should start using a private query buffer" + } } e assert {![client_exists $cname]} $rr close diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl index 89eaf9bbae9..689a59367fc 100644 --- a/tests/unit/maxmemory.tcl +++ b/tests/unit/maxmemory.tcl @@ -355,12 +355,15 @@ proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} # send some 10mb worth of commands that don't increase the memory usage if {$pipeline == 1} { set rd_master [redis_deferring_client -1] + $rd_master client reply off + $rd_master flush for {set k 0} {$k < $cmd_count} {incr k} { $rd_master setrange key:0 0 [string repeat A $payload_len] + if {$k % 10000 == 0} {$rd_master flush} } - for {set k 0} {$k < $cmd_count} {incr k} { - $rd_master read - } + $rd_master client reply on + $rd_master flush + $rd_master read ;# read the +OK from CLIENT REPLY ON } else { for {set k 0} {$k < $cmd_count} {incr k} { $master setrange key:0 0 [string repeat A $payload_len] diff --git a/tests/unit/memefficiency.tcl b/tests/unit/memefficiency.tcl index 4fe0e600606..2df27cf316b 100644 --- a/tests/unit/memefficiency.tcl +++ b/tests/unit/memefficiency.tcl @@ -1,6 +1,8 @@ proc test_memory_efficiency {range} { r flushall set rd [redis_deferring_client] + $rd client reply off + $rd flush set base_mem [s used_memory] set written 0 for {set j 0} {$j < 10000} {incr j} { @@ -11,9 +13,9 @@ proc test_memory_efficiency {range} { incr written [string length $val] incr written 2 ;# A separator is the minimum to store key-value data. } - for {set j 0} {$j < 10000} {incr j} { - $rd read ; # Discard replies - } + $rd client reply on + $rd flush + $rd read ;# read the +OK from CLIENT REPLY ON $rd close set current_mem [s used_memory] @@ -178,15 +180,17 @@ start_server {tags {"defrag external:skip"} overrides {appendonly yes auto-aof-r # Populate memory with interleaving script-key pattern of same size set dummy_script "--[string repeat x 400]\nreturn " set rd [redis_deferring_client] + $rd client reply off + $rd flush for {set j 0} {$j < $n} {incr j} { set val "$dummy_script[format "%06d" $j]" $rd script load $val $rd set k$j $val + if {$j % 100 == 0} {$rd flush} } - for {set j 0} {$j < $n} {incr j} { - $rd read ; # Discard script load replies - $rd read ; # Discard set replies - } + $rd client reply on + $rd flush + $rd read ;# read the +OK from CLIENT REPLY ON after 120 ;# serverCron only updates the info once in 100ms if {$::verbose} { puts "used [s allocator_allocated]" @@ -197,8 +201,15 @@ start_server {tags {"defrag external:skip"} overrides {appendonly yes auto-aof-r assert_lessthan [s allocator_frag_ratio] 1.05 # Delete all the keys to create fragmentation - for {set j 0} {$j < $n} {incr j} { $rd del k$j } - for {set j 0} {$j < $n} {incr j} { $rd read } ; # Discard del replies + $rd client reply off + $rd flush + for {set j 0} {$j < $n} {incr j} { + $rd del k$j + if {$j % 100 == 0} {$rd flush} + } + $rd client reply on + $rd flush + $rd read ;# read the +OK from CLIENT REPLY ON $rd close after 120 ;# serverCron only updates the info once in 100ms if {$::verbose} { diff --git a/tests/unit/moduleapi/test_lazyfree.tcl b/tests/unit/moduleapi/test_lazyfree.tcl index 8d2c55abcf3..89918a28f6c 100644 --- a/tests/unit/moduleapi/test_lazyfree.tcl +++ b/tests/unit/moduleapi/test_lazyfree.tcl @@ -8,13 +8,13 @@ start_server {tags {"modules"}} { set rd [redis_deferring_client] # LAZYFREE_THRESHOLD is 64 + $rd client reply off for {set i 0} {$i < 10000} {incr i} { $rd lazyfreelink.insert lazykey $i + if {$i % 1000 == 0} {$rd flush} } - - for {set j 0} {$j < 10000} {incr j} { - $rd read - } + $rd client reply on + assert_equal OK [$rd read] assert {[r lazyfreelink.len lazykey] == 10000}