Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1849b6456 | ||
|
|
d0f37e247c | ||
|
|
3b67a0f905 | ||
|
|
2c2b6159d3 | ||
|
|
d4945b253b | ||
|
|
53785789a0 | ||
|
|
e7b85b3315 | ||
|
|
a5045d552c | ||
|
|
8939ff1230 | ||
|
|
8b102e041a | ||
|
|
273f41023d | ||
|
|
5bb2565959 | ||
|
|
0692d060b3 | ||
|
|
2e689217d5 | ||
|
|
b76088845c | ||
|
|
8a625029e7 | ||
|
|
8a6b21da61 | ||
|
|
c08eb8e74d | ||
|
|
8b860b36b3 | ||
|
|
61e44f614d | ||
|
|
bc62bc5eac | ||
|
|
67d6b29404 | ||
|
|
901120f8e6 |
@@ -18,6 +18,30 @@ to modify your program in order to use Redis 2.4.
|
||||
CHANGELOG
|
||||
---------
|
||||
|
||||
What's new in Redis 2.4.6
|
||||
=========================
|
||||
|
||||
* [BUGFIX] Fixed issue #141 part 1: Possible protocol desyncs when clients send
|
||||
wrong protocol is now fixed. (See issue 141 for more details)
|
||||
* [BUGFIX] Fixed issue #141 part 2: Connection of multiple slaves used to result
|
||||
from time to time into corrupted protocol send to slaves connected
|
||||
after the first one. (See issue 141 for more details)
|
||||
* [BUGFIX] Do not propagate DEBUG LOADAOF.
|
||||
* New INFO contains information such as ip/port/state for every conneced slave.
|
||||
* Show GCC version in INFO output.
|
||||
|
||||
What's new in Redis 2.4.5
|
||||
=========================
|
||||
|
||||
* [BUGFIX] Fixed a ZUNIONSTORE/ZINTERSTORE bug that can cause a NaN to be
|
||||
inserted as a sorted set element score. This happens when one of the
|
||||
elements has +inf/-inf score and the weight used is 0.
|
||||
* [BUGFIX] Fixed memory leak in CLIENT INFO.
|
||||
* [BUGFIX] Fixed a non critical SORT bug (Issue 224).
|
||||
* [BUGFIX] Fixed a replication bug: now the timeout configuration is respected
|
||||
during the connection with the master.
|
||||
* --quiet option implemented in the Redis test.
|
||||
|
||||
What's new in Redis 2.4.4
|
||||
=========================
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ void debugCommand(redisClient *c) {
|
||||
addReply(c,shared.err);
|
||||
return;
|
||||
}
|
||||
server.dirty = 0; /* Prevent AOF / replication */
|
||||
redisLog(REDIS_WARNING,"Append Only File loaded by DEBUG LOADAOF");
|
||||
addReply(c,shared.ok);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) {
|
||||
|
||||
+38
-7
@@ -1,6 +1,8 @@
|
||||
#include "redis.h"
|
||||
#include <sys/uio.h>
|
||||
|
||||
static void setProtocolError(redisClient *c, int pos);
|
||||
|
||||
void *dupClientReplyValue(void *o) {
|
||||
incrRefCount((robj*)o);
|
||||
return o;
|
||||
@@ -388,6 +390,16 @@ void addReplyBulkLongLong(redisClient *c, long long ll) {
|
||||
addReplyBulkCBuffer(c,buf,len);
|
||||
}
|
||||
|
||||
/* Copy 'src' client output buffers into 'dst' client output buffers.
|
||||
* The function takes care of freeing the old output buffers of the
|
||||
* destination client. */
|
||||
void copyClientOutputBuffer(redisClient *dst, redisClient *src) {
|
||||
listRelease(dst->reply);
|
||||
dst->reply = listDup(src->reply);
|
||||
memcpy(dst->buf,src->buf,src->bufpos);
|
||||
dst->bufpos = src->bufpos;
|
||||
}
|
||||
|
||||
static void acceptCommonHandler(int fd) {
|
||||
redisClient *c;
|
||||
if ((c = createClient(fd)) == NULL) {
|
||||
@@ -668,8 +680,13 @@ int processInlineBuffer(redisClient *c) {
|
||||
size_t querylen;
|
||||
|
||||
/* Nothing to do without a \r\n */
|
||||
if (newline == NULL)
|
||||
if (newline == NULL) {
|
||||
if (sdslen(c->querybuf) > REDIS_INLINE_MAX_SIZE) {
|
||||
addReplyError(c,"Protocol error: too big inline request");
|
||||
setProtocolError(c,0);
|
||||
}
|
||||
return REDIS_ERR;
|
||||
}
|
||||
|
||||
/* Split the input buffer up to the \r\n */
|
||||
querylen = newline-(c->querybuf);
|
||||
@@ -719,8 +736,13 @@ int processMultibulkBuffer(redisClient *c) {
|
||||
|
||||
/* Multi bulk length cannot be read without a \r\n */
|
||||
newline = strchr(c->querybuf,'\r');
|
||||
if (newline == NULL)
|
||||
if (newline == NULL) {
|
||||
if (sdslen(c->querybuf) > REDIS_INLINE_MAX_SIZE) {
|
||||
addReplyError(c,"Protocol error: too big mbulk count string");
|
||||
setProtocolError(c,0);
|
||||
}
|
||||
return REDIS_ERR;
|
||||
}
|
||||
|
||||
/* Buffer should also contain \n */
|
||||
if (newline-(c->querybuf) > ((signed)sdslen(c->querybuf)-2))
|
||||
@@ -754,8 +776,13 @@ int processMultibulkBuffer(redisClient *c) {
|
||||
/* Read bulk length if unknown */
|
||||
if (c->bulklen == -1) {
|
||||
newline = strchr(c->querybuf+pos,'\r');
|
||||
if (newline == NULL)
|
||||
if (newline == NULL) {
|
||||
if (sdslen(c->querybuf) > REDIS_INLINE_MAX_SIZE) {
|
||||
addReplyError(c,"Protocol error: too big bulk count string");
|
||||
setProtocolError(c,0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Buffer should also contain \n */
|
||||
if (newline-(c->querybuf) > ((signed)sdslen(c->querybuf)-2))
|
||||
@@ -796,9 +823,9 @@ int processMultibulkBuffer(redisClient *c) {
|
||||
c->querybuf = sdsrange(c->querybuf,pos,-1);
|
||||
|
||||
/* We're done when c->multibulk == 0 */
|
||||
if (c->multibulklen == 0) {
|
||||
return REDIS_OK;
|
||||
}
|
||||
if (c->multibulklen == 0) return REDIS_OK;
|
||||
|
||||
/* Still not read to process the command */
|
||||
return REDIS_ERR;
|
||||
}
|
||||
|
||||
@@ -956,8 +983,12 @@ sds getAllClientsInfoString(void) {
|
||||
|
||||
listRewind(server.clients,&li);
|
||||
while ((ln = listNext(&li)) != NULL) {
|
||||
sds cs;
|
||||
|
||||
client = listNodeValue(ln);
|
||||
o = sdscatsds(o,getClientInfoString(client));
|
||||
cs = getClientInfoString(client);
|
||||
o = sdscatsds(o,cs);
|
||||
sdsfree(cs);
|
||||
o = sdscatlen(o,"\n",1);
|
||||
}
|
||||
return o;
|
||||
|
||||
+39
@@ -1255,6 +1255,7 @@ sds genRedisInfoString(void) {
|
||||
"redis_git_dirty:%d\r\n"
|
||||
"arch_bits:%s\r\n"
|
||||
"multiplexing_api:%s\r\n"
|
||||
"gcc_version:%d.%d.%d\r\n"
|
||||
"process_id:%ld\r\n"
|
||||
"uptime_in_seconds:%ld\r\n"
|
||||
"uptime_in_days:%ld\r\n"
|
||||
@@ -1297,6 +1298,11 @@ sds genRedisInfoString(void) {
|
||||
strtol(redisGitDirty(),NULL,10) > 0,
|
||||
(sizeof(long) == 8) ? "64" : "32",
|
||||
aeGetApiName(),
|
||||
#ifdef __GNUC__
|
||||
__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__,
|
||||
#else
|
||||
0,0,0,
|
||||
#endif
|
||||
(long) getpid(),
|
||||
uptime,
|
||||
uptime/(3600*24),
|
||||
@@ -1349,6 +1355,39 @@ sds genRedisInfoString(void) {
|
||||
bioPendingJobsOfType(REDIS_BIO_AOF_FSYNC));
|
||||
}
|
||||
|
||||
/* List connected slaves */
|
||||
if (listLength(server.slaves)) {
|
||||
int slaveid = 0;
|
||||
listNode *ln;
|
||||
listIter li;
|
||||
|
||||
listRewind(server.slaves,&li);
|
||||
while((ln = listNext(&li))) {
|
||||
redisClient *slave = listNodeValue(ln);
|
||||
char *state = NULL;
|
||||
char ip[32];
|
||||
int port;
|
||||
|
||||
if (anetPeerToString(slave->fd,ip,&port) == -1) continue;
|
||||
switch(slave->replstate) {
|
||||
case REDIS_REPL_WAIT_BGSAVE_START:
|
||||
case REDIS_REPL_WAIT_BGSAVE_END:
|
||||
state = "wait_bgsave";
|
||||
break;
|
||||
case REDIS_REPL_SEND_BULK:
|
||||
state = "send_bulk";
|
||||
break;
|
||||
case REDIS_REPL_ONLINE:
|
||||
state = "online";
|
||||
break;
|
||||
}
|
||||
if (state == NULL) continue;
|
||||
info = sdscatprintf(info,"slave%d:%s,%d,%s\r\n",
|
||||
slaveid,ip,port,state);
|
||||
slaveid++;
|
||||
}
|
||||
}
|
||||
|
||||
if (server.masterhost) {
|
||||
info = sdscatprintf(info,
|
||||
"master_host:%s\r\n"
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#define REDIS_REQUEST_MAX_SIZE (1024*1024*256) /* max bytes in inline command */
|
||||
#define REDIS_SHARED_INTEGERS 10000
|
||||
#define REDIS_REPLY_CHUNK_BYTES (5*1500) /* 5 TCP packets with default MTU */
|
||||
#define REDIS_INLINE_MAX_SIZE (1024*64) /* Max size of inline reads */
|
||||
#define REDIS_MAX_LOGMSG_LEN 4096 /* Default maximum length of syslog messages */
|
||||
#define REDIS_AUTO_AOFREWRITE_PERC 100
|
||||
#define REDIS_AUTO_AOFREWRITE_MIN_SIZE (1024*1024)
|
||||
@@ -705,6 +706,7 @@ void addReplyStatus(redisClient *c, char *status);
|
||||
void addReplyDouble(redisClient *c, double d);
|
||||
void addReplyLongLong(redisClient *c, long long ll);
|
||||
void addReplyMultiBulkLen(redisClient *c, long length);
|
||||
void copyClientOutputBuffer(redisClient *dst, redisClient *src);
|
||||
void *dupClientReplyValue(void *o);
|
||||
void getClientsMaxBuffers(unsigned long *longest_output_list,
|
||||
unsigned long *biggest_input_buffer);
|
||||
|
||||
+24
-2
@@ -122,8 +122,7 @@ void syncCommand(redisClient *c) {
|
||||
if (ln) {
|
||||
/* Perfect, the server is already registering differences for
|
||||
* another slave. Set the right state, and copy the buffer. */
|
||||
listRelease(c->reply);
|
||||
c->reply = listDup(slave->reply);
|
||||
copyClientOutputBuffer(c,slave);
|
||||
c->replstate = REDIS_REPL_WAIT_BGSAVE_END;
|
||||
redisLog(REDIS_NOTICE,"Waiting for end of BGSAVE for SYNC");
|
||||
} else {
|
||||
@@ -471,11 +470,24 @@ int connectWithMaster(void) {
|
||||
return REDIS_ERR;
|
||||
}
|
||||
|
||||
server.repl_transfer_lastio = time(NULL);
|
||||
server.repl_transfer_s = fd;
|
||||
server.replstate = REDIS_REPL_CONNECTING;
|
||||
return REDIS_OK;
|
||||
}
|
||||
|
||||
/* This function can be called when a non blocking connection is currently
|
||||
* in progress to undo it. */
|
||||
void undoConnectWithMaster(void) {
|
||||
int fd = server.repl_transfer_s;
|
||||
|
||||
redisAssert(server.replstate == REDIS_REPL_CONNECTING);
|
||||
aeDeleteFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE);
|
||||
close(fd);
|
||||
server.repl_transfer_s = -1;
|
||||
server.replstate = REDIS_REPL_CONNECT;
|
||||
}
|
||||
|
||||
void slaveofCommand(redisClient *c) {
|
||||
if (!strcasecmp(c->argv[1]->ptr,"no") &&
|
||||
!strcasecmp(c->argv[2]->ptr,"one")) {
|
||||
@@ -485,6 +497,8 @@ void slaveofCommand(redisClient *c) {
|
||||
if (server.master) freeClient(server.master);
|
||||
if (server.replstate == REDIS_REPL_TRANSFER)
|
||||
replicationAbortSyncTransfer();
|
||||
else if (server.replstate == REDIS_REPL_CONNECTING)
|
||||
undoConnectWithMaster();
|
||||
server.replstate = REDIS_REPL_NONE;
|
||||
redisLog(REDIS_NOTICE,"MASTER MODE enabled (user request)");
|
||||
}
|
||||
@@ -505,6 +519,14 @@ void slaveofCommand(redisClient *c) {
|
||||
/* --------------------------- REPLICATION CRON ---------------------------- */
|
||||
|
||||
void replicationCron(void) {
|
||||
/* Non blocking connection timeout? */
|
||||
if (server.masterhost && server.replstate == REDIS_REPL_CONNECTING &&
|
||||
(time(NULL)-server.repl_transfer_lastio) > server.repl_timeout)
|
||||
{
|
||||
redisLog(REDIS_WARNING,"Timeout connecting to the MASTER...");
|
||||
undoConnectWithMaster();
|
||||
}
|
||||
|
||||
/* Bulk transfer I/O timeout? */
|
||||
if (server.masterhost && server.replstate == REDIS_REPL_TRANSFER &&
|
||||
(time(NULL)-server.repl_transfer_lastio) > server.repl_timeout)
|
||||
|
||||
+9
-12
@@ -141,11 +141,7 @@ void sortCommand(redisClient *c) {
|
||||
|
||||
/* Lookup the key to sort. It must be of the right types */
|
||||
sortval = lookupKeyRead(c->db,c->argv[1]);
|
||||
if (sortval == NULL) {
|
||||
addReply(c,shared.emptymultibulk);
|
||||
return;
|
||||
}
|
||||
if (sortval->type != REDIS_SET && sortval->type != REDIS_LIST &&
|
||||
if (sortval && sortval->type != REDIS_SET && sortval->type != REDIS_LIST &&
|
||||
sortval->type != REDIS_ZSET)
|
||||
{
|
||||
addReply(c,shared.wrongtypeerr);
|
||||
@@ -161,7 +157,10 @@ void sortCommand(redisClient *c) {
|
||||
/* Now we need to protect sortval incrementing its count, in the future
|
||||
* SORT may have options able to overwrite/delete keys during the sorting
|
||||
* and the sorted key itself may get destroied */
|
||||
incrRefCount(sortval);
|
||||
if (sortval)
|
||||
incrRefCount(sortval);
|
||||
else
|
||||
sortval = createListObject();
|
||||
|
||||
/* The SORT command has an SQL-alike syntax, parse it */
|
||||
while(j < c->argc) {
|
||||
@@ -200,7 +199,8 @@ void sortCommand(redisClient *c) {
|
||||
}
|
||||
|
||||
/* Destructively convert encoded sorted sets for SORT. */
|
||||
if (sortval->type == REDIS_ZSET) zsetConvert(sortval, REDIS_ENCODING_SKIPLIST);
|
||||
if (sortval->type == REDIS_ZSET)
|
||||
zsetConvert(sortval, REDIS_ENCODING_SKIPLIST);
|
||||
|
||||
/* Load the sorting vector with all the objects to sort */
|
||||
switch(sortval->type) {
|
||||
@@ -366,12 +366,9 @@ void sortCommand(redisClient *c) {
|
||||
}
|
||||
}
|
||||
}
|
||||
setKey(c->db,storekey,sobj);
|
||||
if (outputlen) setKey(c->db,storekey,sobj);
|
||||
decrRefCount(sobj);
|
||||
/* Note: we add 1 because the DB is dirty anyway since even if the
|
||||
* SORT result is empty a new key is set and maybe the old content
|
||||
* replaced. */
|
||||
server.dirty += 1+outputlen;
|
||||
server.dirty += outputlen;
|
||||
addReplyLongLong(c,outputlen);
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -17,7 +17,7 @@
|
||||
/* This skiplist implementation is almost a C translation of the original
|
||||
* algorithm described by William Pugh in "Skip Lists: A Probabilistic
|
||||
* Alternative to Balanced Trees", modified in three ways:
|
||||
* a) this implementation allows for repeated values.
|
||||
* a) this implementation allows for repeated scores.
|
||||
* b) the comparison is not just by key (our 'score') but by satellite data.
|
||||
* c) there is a back pointer, so it's a doubly linked list with the back
|
||||
* pointers being only at "level 1". This allows to traverse the list
|
||||
@@ -76,6 +76,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) {
|
||||
unsigned int rank[ZSKIPLIST_MAXLEVEL];
|
||||
int i, level;
|
||||
|
||||
redisAssert(!isnan(score));
|
||||
x = zsl->header;
|
||||
for (i = zsl->level-1; i >= 0; i--) {
|
||||
/* store rank that is crossed to reach the insert position */
|
||||
@@ -1547,6 +1548,8 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
||||
double score, value;
|
||||
|
||||
score = src[0].weight * zval.score;
|
||||
if (isnan(score)) score = 0;
|
||||
|
||||
for (j = 1; j < setnum; j++) {
|
||||
/* It is not safe to access the zset we are
|
||||
* iterating, so explicitly check for equal object. */
|
||||
@@ -1589,6 +1592,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
||||
|
||||
/* Initialize score */
|
||||
score = src[i].weight * zval.score;
|
||||
if (isnan(score)) score = 0;
|
||||
|
||||
/* Because the inputs are sorted by size, it's only possible
|
||||
* for sets at larger indices to hold this element. */
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
#define REDIS_VERSION "2.4.4"
|
||||
#define REDIS_VERSION "2.4.6"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
source tests/support/redis.tcl
|
||||
|
||||
proc gen_write_load {host port seconds} {
|
||||
set start_time [clock seconds]
|
||||
set r [redis $host $port 1]
|
||||
$r select 9
|
||||
while 1 {
|
||||
$r set [expr rand()] [expr rand()]
|
||||
if {[clock seconds]-$start_time > $seconds} {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2]
|
||||
+26
-14
@@ -31,14 +31,20 @@ tags {"aof"} {
|
||||
}
|
||||
|
||||
start_server_aof [list dir $server_path] {
|
||||
test "Unfinished MULTI: Server should not have been started" {
|
||||
if {$::valgrind} {after 2000}
|
||||
assert_equal 0 [is_alive $srv]
|
||||
}
|
||||
|
||||
test "Unfinished MULTI: Server should have logged an error" {
|
||||
set result [exec cat [dict get $srv stdout] | tail -n1]
|
||||
assert_match "*Unexpected end of file reading the append only file*" $result
|
||||
set pattern "*Unexpected end of file reading the append only file*"
|
||||
set retry 10
|
||||
while {$retry} {
|
||||
set result [exec cat [dict get $srv stdout] | tail -n1]
|
||||
if {[string match $pattern $result]} {
|
||||
break
|
||||
}
|
||||
incr retry -1
|
||||
after 1000
|
||||
}
|
||||
if {$retry == 0} {
|
||||
error "assertion:expected error not found on config file"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,14 +55,20 @@ tags {"aof"} {
|
||||
}
|
||||
|
||||
start_server_aof [list dir $server_path] {
|
||||
test "Short read: Server should not have been started" {
|
||||
if {$::valgrind} {after 2000}
|
||||
assert_equal 0 [is_alive $srv]
|
||||
}
|
||||
|
||||
test "Short read: Server should have logged an error" {
|
||||
set result [exec cat [dict get $srv stdout] | tail -n1]
|
||||
assert_match "*Bad file format reading the append only file*" $result
|
||||
set pattern "*Bad file format reading the append only file*"
|
||||
set retry 10
|
||||
while {$retry} {
|
||||
set result [exec cat [dict get $srv stdout] | tail -n1]
|
||||
if {[string match $pattern $result]} {
|
||||
break
|
||||
}
|
||||
incr retry -1
|
||||
after 1000
|
||||
}
|
||||
if {$retry == 0} {
|
||||
error "assertion:expected error not found on config file"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,3 +65,71 @@ start_server {tags {"repl"}} {
|
||||
} {0 0}
|
||||
}
|
||||
}
|
||||
|
||||
proc start_write_load {host port seconds} {
|
||||
exec tclsh8.5 tests/helpers/gen_write_load.tcl $host $port $seconds &
|
||||
}
|
||||
|
||||
proc stop_write_load {handle} {
|
||||
catch {exec /bin/kill -9 $handle}
|
||||
}
|
||||
|
||||
start_server {tags {"repl"}} {
|
||||
set master [srv 0 client]
|
||||
set master_host [srv 0 host]
|
||||
set master_port [srv 0 port]
|
||||
set slaves {}
|
||||
set load_handle0 [start_write_load $master_host $master_port 20]
|
||||
set load_handle1 [start_write_load $master_host $master_port 20]
|
||||
set load_handle2 [start_write_load $master_host $master_port 20]
|
||||
set load_handle3 [start_write_load $master_host $master_port 20]
|
||||
set load_handle4 [start_write_load $master_host $master_port 20]
|
||||
after 2000
|
||||
start_server {} {
|
||||
lappend slaves [srv 0 client]
|
||||
start_server {} {
|
||||
lappend slaves [srv 0 client]
|
||||
start_server {} {
|
||||
lappend slaves [srv 0 client]
|
||||
test "Connect multiple slaves at the same time (issue #141)" {
|
||||
[lindex $slaves 0] slaveof $master_host $master_port
|
||||
[lindex $slaves 1] slaveof $master_host $master_port
|
||||
[lindex $slaves 2] slaveof $master_host $master_port
|
||||
|
||||
# Wait for all the three slaves to reach the "online" state
|
||||
set retry 100
|
||||
while {$retry} {
|
||||
set info [r -3 info]
|
||||
if {[string match {*slave0:*,online*slave1:*,online*slave2:*,online*} $info]} {
|
||||
break
|
||||
} else {
|
||||
incr retry -1
|
||||
after 100
|
||||
}
|
||||
}
|
||||
if {$retry == 0} {
|
||||
error "assertion:Slaves not correctly synchronized"
|
||||
}
|
||||
stop_write_load $load_handle0
|
||||
stop_write_load $load_handle1
|
||||
stop_write_load $load_handle2
|
||||
stop_write_load $load_handle3
|
||||
stop_write_load $load_handle4
|
||||
after 1000
|
||||
set digest [$master debug digest]
|
||||
set digest0 [[lindex $slaves 0] debug digest]
|
||||
set digest1 [[lindex $slaves 1] debug digest]
|
||||
set digest2 [[lindex $slaves 2] debug digest]
|
||||
assert {$digest ne 0000000000000000000000000000000000000000}
|
||||
assert {$digest eq $digest0}
|
||||
assert {$digest eq $digest1}
|
||||
assert {$digest eq $digest2}
|
||||
#puts [$master dbsize]
|
||||
#puts [[lindex $slaves 0] dbsize]
|
||||
#puts [[lindex $slaves 1] dbsize]
|
||||
#puts [[lindex $slaves 2] dbsize]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ set ::num_failed 0
|
||||
set ::tests_failed {}
|
||||
|
||||
proc assert {condition} {
|
||||
if {![uplevel 1 expr $condition]} {
|
||||
error "assertion:Expected condition '$condition' to be true"
|
||||
if {![uplevel 1 [list expr $condition]]} {
|
||||
error "assertion:Expected condition '$condition' to be true ([uplevel 1 [list subst -nocommands $condition]])"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-12
@@ -32,6 +32,7 @@ set ::all_tests {
|
||||
unit/pubsub
|
||||
unit/slowlog
|
||||
unit/maxmemory
|
||||
unit/introspection
|
||||
}
|
||||
# Index to the next test to run in the ::all_tests list.
|
||||
set ::next_test 0
|
||||
@@ -41,6 +42,7 @@ set ::port 21111
|
||||
set ::traceleaks 0
|
||||
set ::valgrind 0
|
||||
set ::verbose 0
|
||||
set ::quiet 0
|
||||
set ::denytags {}
|
||||
set ::allowtags {}
|
||||
set ::external 0; # If "1" this means, we are running against external instance
|
||||
@@ -111,7 +113,7 @@ proc reconnect {args} {
|
||||
}
|
||||
|
||||
# re-set $srv in the servers list
|
||||
set ::servers [lreplace $::servers end+$level 1 $srv]
|
||||
lset ::servers end+$level $srv
|
||||
}
|
||||
|
||||
proc redis_deferring_client {args} {
|
||||
@@ -141,19 +143,19 @@ proc s {args} {
|
||||
}
|
||||
|
||||
proc cleanup {} {
|
||||
puts -nonewline "Cleanup: may take some time... "
|
||||
if {!$::quiet} {puts -nonewline "Cleanup: may take some time... "}
|
||||
flush stdout
|
||||
catch {exec rm -rf {*}[glob tests/tmp/redis.conf.*]}
|
||||
catch {exec rm -rf {*}[glob tests/tmp/server.*]}
|
||||
puts "OK"
|
||||
if {!$::quiet} {puts "OK"}
|
||||
}
|
||||
|
||||
proc find_available_port start {
|
||||
for {set j $start} {$j < $start+1024} {incr j} {
|
||||
if {[catch {
|
||||
set fd [socket 127.0.0.1 $start]
|
||||
set fd [socket 127.0.0.1 $j]
|
||||
}]} {
|
||||
return $start
|
||||
return $j
|
||||
} else {
|
||||
close $fd
|
||||
}
|
||||
@@ -168,7 +170,9 @@ proc test_server_main {} {
|
||||
# Open a listening socket, trying different ports in order to find a
|
||||
# non busy one.
|
||||
set port [find_available_port 11111]
|
||||
puts "Starting test server at port $port"
|
||||
if {!$::quiet} {
|
||||
puts "Starting test server at port $port"
|
||||
}
|
||||
socket -server accept_test_clients $port
|
||||
|
||||
# Start the client instances
|
||||
@@ -222,16 +226,22 @@ proc read_from_test_client fd {
|
||||
set payload [read $fd $bytes]
|
||||
foreach {status data} $payload break
|
||||
if {$status eq {ready}} {
|
||||
puts "\[$status\]: $data"
|
||||
if {!$::quiet} {
|
||||
puts "\[$status\]: $data"
|
||||
}
|
||||
signal_idle_client $fd
|
||||
} elseif {$status eq {done}} {
|
||||
set elapsed [expr {[clock seconds]-$::clients_start_time($fd)}]
|
||||
puts "\[[colorstr yellow $status]\]: $data ($elapsed seconds)"
|
||||
puts "+++ [expr {[llength $::active_clients]-1}] units still in execution."
|
||||
set all_tests_count [llength $::all_tests]
|
||||
set running_tests_count [expr {[llength $::active_clients]-1}]
|
||||
set completed_tests_count [expr {$::next_test-$running_tests_count}]
|
||||
puts "\[$completed_tests_count/$all_tests_count [colorstr yellow $status]\]: $data ($elapsed seconds)"
|
||||
lappend ::clients_time_history $elapsed $data
|
||||
signal_idle_client $fd
|
||||
} elseif {$status eq {ok}} {
|
||||
puts "\[[colorstr green $status]\]: $data"
|
||||
if {!$::quiet} {
|
||||
puts "\[[colorstr green $status]\]: $data"
|
||||
}
|
||||
} elseif {$status eq {err}} {
|
||||
set err "\[[colorstr red $status]\]: $data"
|
||||
puts $err
|
||||
@@ -245,7 +255,9 @@ proc read_from_test_client fd {
|
||||
} elseif {$status eq {testing}} {
|
||||
# No op
|
||||
} else {
|
||||
puts "\[$status\]: $data"
|
||||
if {!$::quiet} {
|
||||
puts "\[$status\]: $data"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +269,9 @@ proc signal_idle_client fd {
|
||||
[lsearch -all -inline -not -exact $::active_clients $fd]
|
||||
# New unit to process?
|
||||
if {$::next_test != [llength $::all_tests]} {
|
||||
puts [colorstr bold-white "Testing [lindex $::all_tests $::next_test]"]
|
||||
if {!$::quiet} {
|
||||
puts [colorstr bold-white "Testing [lindex $::all_tests $::next_test]"]
|
||||
}
|
||||
set ::clients_start_time($fd) [clock seconds]
|
||||
send_data_packet $fd run [lindex $::all_tests $::next_test]
|
||||
lappend ::active_clients $fd
|
||||
@@ -321,6 +335,7 @@ proc print_help_screen {} {
|
||||
puts [join {
|
||||
"--valgrind Run the test over valgrind."
|
||||
"--accurate Run slow randomized tests for more iterations."
|
||||
"--quiet Don't show individual tests."
|
||||
"--single <unit> Just execute the specified unit (see next option)."
|
||||
"--list-tests List all the available test units."
|
||||
"--force-failure Force the execution of a test that always fails."
|
||||
@@ -343,6 +358,8 @@ for {set j 0} {$j < [llength $argv]} {incr j} {
|
||||
incr j
|
||||
} elseif {$opt eq {--valgrind}} {
|
||||
set ::valgrind 1
|
||||
} elseif {$opt eq {--quiet}} {
|
||||
set ::quiet 1
|
||||
} elseif {$opt eq {--host}} {
|
||||
set ::external 1
|
||||
set ::host $arg
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
start_server {tags {"introspection"}} {
|
||||
test {CLIENT LIST} {
|
||||
r client list
|
||||
} {*addr=*:* fd=* idle=* flags=N db=9 sub=0 psub=0 qbuf=0 obl=0 oll=0 events=r cmd=client*}
|
||||
}
|
||||
@@ -59,4 +59,35 @@ start_server {tags {"protocol"}} {
|
||||
reconnect
|
||||
assert_error "*wrong*arguments*ping*" {r ping x y z}
|
||||
}
|
||||
|
||||
set c 0
|
||||
foreach seq [list "\x00" "*\x00" "$\x00"] {
|
||||
incr c
|
||||
test "Protocol desync regression test #$c" {
|
||||
set s [socket [srv 0 host] [srv 0 port]]
|
||||
puts -nonewline $s $seq
|
||||
set payload [string repeat A 1024]"\n"
|
||||
set test_start [clock seconds]
|
||||
set test_time_limit 5
|
||||
while 1 {
|
||||
if {[catch {
|
||||
puts -nonewline $s payload
|
||||
flush $s
|
||||
incr payload_size [string length $payload]
|
||||
}]} {
|
||||
set retval [gets $s]
|
||||
close $s
|
||||
break
|
||||
} else {
|
||||
set elapsed [expr {[clock seconds]-$test_start}]
|
||||
if {$elapsed > $test_time_limit} {
|
||||
close $s
|
||||
error "assertion:Redis did not closed connection after protocol desync"
|
||||
}
|
||||
}
|
||||
}
|
||||
set retval
|
||||
} {*Protocol error*}
|
||||
}
|
||||
unset c
|
||||
}
|
||||
|
||||
@@ -134,6 +134,18 @@ start_server {
|
||||
assert_equal [lsort -real $floats] [r sort mylist]
|
||||
}
|
||||
|
||||
test "SORT with STORE returns zero if result is empty (github isse 224)" {
|
||||
r flushdb
|
||||
r sort foo store bar
|
||||
} {0}
|
||||
|
||||
test "SORT with STORE does not create empty lists (github issue 224)" {
|
||||
r flushdb
|
||||
r lpush foo bar
|
||||
r sort foo limit 10 10 store zap
|
||||
r exists zap
|
||||
} {0}
|
||||
|
||||
tags {"slow"} {
|
||||
set num 100
|
||||
set res [create_random_dataset $num lpush]
|
||||
|
||||
@@ -518,6 +518,12 @@ start_server {tags {"zset"}} {
|
||||
r zinterstore set3 2 set1 set2
|
||||
} {0}
|
||||
|
||||
test {ZUNIONSTORE regression, should not create NaN in scores} {
|
||||
r zadd z -inf neginf
|
||||
r zunionstore out 1 z weights 0
|
||||
r zrange out 0 -1 withscores
|
||||
} {neginf 0}
|
||||
|
||||
proc stressers {encoding} {
|
||||
if {$encoding == "ziplist"} {
|
||||
# Little extra to allow proper fuzzing in the sorting stresser
|
||||
|
||||
Reference in New Issue
Block a user