mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
DEBUG RELOAD implemented, and test-redis.tcl modified to use it to check for persistence consistency.
This commit is contained in:
parent
1c0abf3c5d
commit
210e29f7d2
14
redis.c
14
redis.c
@ -5742,6 +5742,18 @@ fmterr:
|
|||||||
static void debugCommand(redisClient *c) {
|
static void debugCommand(redisClient *c) {
|
||||||
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
|
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
|
||||||
*((char*)-1) = 'x';
|
*((char*)-1) = 'x';
|
||||||
|
} else if (!strcasecmp(c->argv[1]->ptr,"reload")) {
|
||||||
|
if (rdbSave(server.dbfilename) != REDIS_OK) {
|
||||||
|
addReply(c,shared.err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emptyDb();
|
||||||
|
if (rdbLoad(server.dbfilename) != REDIS_OK) {
|
||||||
|
addReply(c,shared.err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
redisLog(REDIS_WARNING,"DB reloaded by DEBUG RELOAD");
|
||||||
|
addReply(c,shared.ok);
|
||||||
} else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) {
|
} else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) {
|
||||||
dictEntry *de = dictFind(c->db->dict,c->argv[2]);
|
dictEntry *de = dictFind(c->db->dict,c->argv[2]);
|
||||||
robj *key, *val;
|
robj *key, *val;
|
||||||
@ -5757,7 +5769,7 @@ static void debugCommand(redisClient *c) {
|
|||||||
key, key->refcount, val, val->refcount, val->encoding));
|
key, key->refcount, val, val->refcount, val->encoding));
|
||||||
} else {
|
} else {
|
||||||
addReplySds(c,sdsnew(
|
addReplySds(c,sdsnew(
|
||||||
"-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>]\r\n"));
|
"-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>|RELOAD]\r\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +235,19 @@ proc main {server port} {
|
|||||||
format $ok
|
format $ok
|
||||||
} {2000}
|
} {2000}
|
||||||
|
|
||||||
|
test {Check if the list is still ok after a DEBUG RELOAD} {
|
||||||
|
$r debug reload
|
||||||
|
set ok 0
|
||||||
|
for {set i 0} {$i < 1000} {incr i} {
|
||||||
|
set rint [expr int(rand()*1000)]
|
||||||
|
if {[$r lindex mylist $rint] eq $rint} {incr ok}
|
||||||
|
if {[$r lindex mylist [expr (-$rint)-1]] eq [expr 999-$rint]} {
|
||||||
|
incr ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
format $ok
|
||||||
|
} {2000}
|
||||||
|
|
||||||
test {LLEN against non-list value error} {
|
test {LLEN against non-list value error} {
|
||||||
$r del mylist
|
$r del mylist
|
||||||
$r set mylist foobar
|
$r set mylist foobar
|
||||||
@ -551,6 +564,12 @@ proc main {server port} {
|
|||||||
lsort [$r smembers setres]
|
lsort [$r smembers setres]
|
||||||
} {995 996 997 998 999}
|
} {995 996 997 998 999}
|
||||||
|
|
||||||
|
test {SINTERSTORE with two sets, after a DEBUG RELOAD} {
|
||||||
|
$r debug reload
|
||||||
|
$r sinterstore setres set1 set2
|
||||||
|
lsort [$r smembers setres]
|
||||||
|
} {995 996 997 998 999}
|
||||||
|
|
||||||
test {SUNIONSTORE with two sets} {
|
test {SUNIONSTORE with two sets} {
|
||||||
$r sunionstore setres set1 set2
|
$r sunionstore setres set1 set2
|
||||||
lsort [$r smembers setres]
|
lsort [$r smembers setres]
|
||||||
@ -906,6 +925,25 @@ proc main {server port} {
|
|||||||
set _ $err
|
set _ $err
|
||||||
} {}
|
} {}
|
||||||
|
|
||||||
|
test {ZSCORE after a DEBUG RELOAD} {
|
||||||
|
set aux {}
|
||||||
|
set err {}
|
||||||
|
$r del zscoretest
|
||||||
|
for {set i 0} {$i < 1000} {incr i} {
|
||||||
|
set score [expr rand()]
|
||||||
|
lappend aux $score
|
||||||
|
$r zadd zscoretest $score $i
|
||||||
|
}
|
||||||
|
$r debug reload
|
||||||
|
for {set i 0} {$i < 1000} {incr i} {
|
||||||
|
if {[$r zscore zscoretest $i] != [lindex $aux $i]} {
|
||||||
|
set err "Expected score was [lindex $aux $i] but got [$r zscore zscoretest $i] for element $i"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set _ $err
|
||||||
|
} {}
|
||||||
|
|
||||||
test {ZRANGE and ZREVRANGE} {
|
test {ZRANGE and ZREVRANGE} {
|
||||||
list [$r zrange ztmp 0 -1] [$r zrevrange ztmp 0 -1]
|
list [$r zrange ztmp 0 -1] [$r zrevrange ztmp 0 -1]
|
||||||
} {{y x z} {z x y}}
|
} {{y x z} {z x y}}
|
||||||
|
Loading…
Reference in New Issue
Block a user