Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtest
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtest-cluster
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtest-moduleapi
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion runtest-sentinel
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/call_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/listpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ziplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
7 changes: 4 additions & 3 deletions tests/cluster/tests/17-diskless-load-swapdb.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/corrupt-dump-fuzzer.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/failover.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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} {
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/rdb.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions tests/test_helper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ proc print_help_screen {} {
"--timeout <sec> Test timeout in seconds (default 20 min)."
"--force-failure Force the execution of a test that always fails."
"--config <k> <v> Extra config file argument."
"--io-threads Run tests with IO threads enabled."
"--skipfile <file> Name of a file containing test names or regexp patterns (if <test> starts with '/') that should be skipped (one per line). This option can be repeated."
"--skiptest <test> Test name or regexp pattern (if <test> starts with '/') to skip. This option can be repeated."
"--tags <tags> Run only tests having specified tags or not having '-' prefixed tags."
Expand Down Expand Up @@ -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}} {
Expand Down
18 changes: 16 additions & 2 deletions tests/unit/client-eviction.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/maxmemory.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
29 changes: 20 additions & 9 deletions tests/unit/memefficiency.tcl
Original file line number Diff line number Diff line change
@@ -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} {
Expand All @@ -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]
Expand Down Expand Up @@ -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]"
Expand All @@ -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} {
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/moduleapi/test_lazyfree.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Loading