Compare commits

..

30 Commits

Author SHA1 Message Date
antirez
4e4b3b943c Redis 2.1.1, release notes updated 2011-02-23 15:48:24 +01:00
Pieter Noordhuis
61e2547675 Restore argc/argv in EXEC after command is executed 2011-02-23 09:39:29 +01:00
antirez
595b5974f8 fixed client-libraries/README to reflect the new site path instead of google code 2011-02-22 18:22:00 +01:00
antirez
58418d7c3e linenoise updated 2011-02-22 17:40:33 +01:00
antirez
c02bda324f fixed color support for test suite. Now colors are shown as long as there is xterm somewhere inside the TERM env var 2011-02-22 16:40:24 +01:00
Paul Gideon Dann
1afef16d88 Allow port to be 0 in configuration, in order to allow disabling of TCP. 2011-02-22 12:12:30 +01:00
antirez
7377aacd84 seed the random number generator at startup 2011-02-22 00:01:48 +01:00
antirez
eece2d528c suppress a Linux warning, for 2.2 sake 2011-02-21 17:50:54 +01:00
antirez
eb5aeaf138 check return value of getcwd() 2011-02-21 17:41:25 +01:00
antirez
1a6281f52f version bumped to 2.2.0 and release notes added 2011-02-17 17:15:52 +01:00
antirez
c2571b314a CONFIG SET/GET for all the special encoding parameters of sets, lists, hashes 2011-02-17 12:21:22 +01:00
Pieter Noordhuis
97aeda9828 Morph SPOP to SREM for correct behavior on log replay/replication 2011-02-16 00:24:54 +01:00
antirez
ca9d961073 CONFIG GET/SET dir implemented 2011-02-14 02:51:49 +01:00
antirez
2446fbb3bb Merge remote branch 'pietern/2.2-brpoplpush' into 2.2 2011-02-07 15:27:45 +01:00
antirez
970e813be2 Fix for the previous port 0 patch, thanks to Pieter for noticing the error 2011-02-07 13:43:55 +01:00
antirez
a36d524562 If port zero is specified, Redis will not listen for TCP connections 2011-02-07 12:52:40 +01:00
Pieter Noordhuis
bbaf76ea2f Clarify comment 2011-01-31 16:50:17 +01:00
Pieter Noordhuis
669f302e16 Reply with single null bulk for unsuccesful BRPOPLPUSH 2011-01-31 16:50:00 +01:00
antirez
71791e7a8e propagate key eviction to slaves and AOF, like for expires, so that replicas and AOFs are always consistent even in maxmemory mode. 2011-01-27 16:53:23 +01:00
antirez
2f91d7ada4 add tarball script added 2011-01-25 10:45:53 +01:00
antirez
5ef8f9531d other minor README changes 2011-01-25 10:26:00 +01:00
antirez
3ce30a6906 README updated 2011-01-25 10:25:05 +01:00
antirez
65e79a8272 release noted updated, version bumped to 2.1.12 (2.2.0 RC4) 2011-01-25 10:21:13 +01:00
antirez
ef8bc13d0d Merge branch '2.2' of github.com:antirez/redis into 2.2 2011-01-24 10:07:18 +01:00
antirez
0ffeadd290 portability fix in redis benchmark, using zu format specified with size_t instead of lu 2011-01-24 10:06:09 +01:00
antirez
db0e263b42 Fixed issue #435 and at the same time introduced explicit ping in the master-slave channel that will detect a blocked master or a broken even if apparently connected TCP link. 2011-01-20 18:02:51 +01:00
antirez
d526d09e41 Merge branch '2.2' of github.com:antirez/redis into 2.2 2011-01-20 16:50:02 +01:00
antirez
9738e587da Fixed compilation on FreeBSD 2011-01-20 10:59:25 +01:00
antirez
da67b5f59a typo fixed in release notes for 2.2.0 RC3 2011-01-17 12:21:59 +01:00
antirez
825d2904d1 release notes updated for 2.2.0 RC3 2011-01-17 12:19:15 +01:00
18 changed files with 232 additions and 27 deletions

View File

@@ -8,6 +8,53 @@ cases, basicaly it is very unlikely that you will experience any problem
upgrading your 2.0 instances to 2.2, as 2.2 can work as a drop in replacement
for 2.0.
---------
CHANGELOG
---------
What's new in Redis 2.2.1
=========================
Redis 2.2.1 is a bugfix release. Changelog:
* Fixed an SPOP crash. When using SPOP in a MULTI/EXEC block there was a problem
introduced in the latest release when fixing an SPOP replication/AOF related
bug.
What's new in Redis 2.2.0 final
===============================
Redis 2.2.0 final is both a bug fix and minor enhancement release:
* SPOP is now replicated correctly in AOF and across slaves.
* CONFIG SET/GET for all the special encoding parameters of sets, lists, hashes.
* Now BRPOPLPUSH will reply with single null bulk on timeout.
* Specifying port 0 in redis.conf will tell Redis to don't listen on TCP socket.
* Propagate key eviction to slaves and AOF, similarly to expires.
What's new in Redis 2.1.10 (2.2 Release Candidate 4)
====================================================
Redis 2.2 RC4 is a bug fix and minor enhancement release:
* Fixed timeout error in replication where master took a big time to BGSAVE.
* Introduced explicit PING between master and slave, to reliably detect when
the link is down, even if the socket remains apparently connected.
* Fixed compilation on FreeBSD.
* Removed a small portability issue in redis-benchmark.
What's new in Redis 2.1.10 (2.2 Release Candidate 3)
====================================================
Redis 2.2 RC3 is a bug fix and minor enhancements release:
* Solaris fixes
* Fixes and improvements for redis-benchmark
* New INFO field with memory allocation details
* New INFO fields with info about clients max input/output buffer
* Replication: KEYS fixed in slaves
* Different default thresholds for Hash type memory saving encodings
What's new in Redis 2.1.10 (2.2 Release Candidate 2)
====================================================

9
README
View File

@@ -2,10 +2,7 @@ Where to find complete Redis documentation?
-------------------------------------------
This README is just a fast "quick start" document. You can find more detailed
documentation here:
1) http://code.google.com/p/redis
2) Check the 'doc' directory. doc/README.html is a good starting point :)
documentation at http://redis.io
Building Redis
--------------
@@ -23,7 +20,7 @@ You can run a 32 bit Redis binary using:
% make 32bit
After you build Redis is a good idea to test it, using:
After building Redis is a good idea to test it, using:
% make test
@@ -80,7 +77,7 @@ then in another terminal try the following:
You can find the list of all the available commands here:
http://code.google.com/p/redis/wiki/CommandReference
http://redis.io/commands
Enjoy!

View File

@@ -1,6 +1,6 @@
An updated list of client libraries for Redis can be found here:
http://code.google.com/p/redis
http://redis.io/clients
All the links are in the front page.

View File

@@ -320,10 +320,9 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
switch(c) {
case 13: /* enter */
case 4: /* ctrl-d */
history_len--;
free(history[history_len]);
return (len == 0 && c == 4) ? -1 : (int)len;
return (int)len;
case 3: /* ctrl-c */
errno = EAGAIN;
return -1;
@@ -337,6 +336,18 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
refreshLine(fd,prompt,buf,len,pos,cols);
}
break;
case 4: /* ctrl-d, remove char at right of cursor */
if (len > 1 && pos < (len-1)) {
memmove(buf+pos,buf+pos+1,len-pos);
len--;
buf[len] = '\0';
refreshLine(fd,prompt,buf,len,pos,cols);
} else if (len == 0) {
history_len--;
free(history[history_len]);
return -1;
}
break;
case 20: /* ctrl-t */
if (pos > 0 && pos < len) {
int aux = buf[pos-1];

View File

@@ -21,6 +21,7 @@ daemonize no
pidfile /var/run/redis.pid
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
# If you want you can bind a single interface, if the bind option is not

View File

@@ -66,7 +66,7 @@ void loadServerConfig(char *filename) {
}
} else if (!strcasecmp(argv[0],"port") && argc == 2) {
server.port = atoi(argv[1]);
if (server.port < 1 || server.port > 65535) {
if (server.port < 0 || server.port > 65535) {
err = "Invalid port"; goto loaderr;
}
} else if (!strcasecmp(argv[0],"bind") && argc == 2) {
@@ -426,6 +426,26 @@ void configSetCommand(redisClient *c) {
if (yn == -1) goto badfmt;
server.repl_serve_stale_data = yn;
} else if (!strcasecmp(c->argv[2]->ptr,"dir")) {
if (chdir((char*)o->ptr) == -1) {
addReplyErrorFormat(c,"Changing directory: %s", strerror(errno));
return;
}
} else if (!strcasecmp(c->argv[2]->ptr,"hash-max-zipmap-entries")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
server.hash_max_zipmap_entries = ll;
} else if (!strcasecmp(c->argv[2]->ptr,"hash-max-zipmap-value")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
server.hash_max_zipmap_value = ll;
} else if (!strcasecmp(c->argv[2]->ptr,"list-max-ziplist-entries")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
server.list_max_ziplist_entries = ll;
} else if (!strcasecmp(c->argv[2]->ptr,"list-max-ziplist-value")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
server.list_max_ziplist_value = ll;
} else if (!strcasecmp(c->argv[2]->ptr,"set-max-intset-entries")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
server.set_max_intset_entries = ll;
} else {
addReplyErrorFormat(c,"Unsupported CONFIG parameter: %s",
(char*)c->argv[2]->ptr);
@@ -448,6 +468,17 @@ void configGetCommand(redisClient *c) {
int matches = 0;
redisAssert(o->encoding == REDIS_ENCODING_RAW);
if (stringmatch(pattern,"dir",0)) {
char buf[1024];
addReplyBulkCString(c,"dir");
if (getcwd(buf,sizeof(buf)) == NULL) {
buf[0] = '\0';
} else {
addReplyBulkCString(c,buf);
}
matches++;
}
if (stringmatch(pattern,"dbfilename",0)) {
addReplyBulkCString(c,"dbfilename");
addReplyBulkCString(c,server.dbfilename);
@@ -541,6 +572,31 @@ void configGetCommand(redisClient *c) {
addReplyBulkCString(c,server.repl_serve_stale_data ? "yes" : "no");
matches++;
}
if (stringmatch(pattern,"hash-max-zipmap-entries",0)) {
addReplyBulkCString(c,"hash-max-zipmap-entries");
addReplyBulkLongLong(c,server.hash_max_zipmap_entries);
matches++;
}
if (stringmatch(pattern,"hash-max-zipmap-value",0)) {
addReplyBulkCString(c,"hash-max-zipmap-value");
addReplyBulkLongLong(c,server.hash_max_zipmap_value);
matches++;
}
if (stringmatch(pattern,"list-max-ziplist-entries",0)) {
addReplyBulkCString(c,"list-max-ziplist-entries");
addReplyBulkLongLong(c,server.list_max_ziplist_entries);
matches++;
}
if (stringmatch(pattern,"list-max-ziplist-value",0)) {
addReplyBulkCString(c,"list-max-ziplist-value");
addReplyBulkLongLong(c,server.list_max_ziplist_value);
matches++;
}
if (stringmatch(pattern,"set-max-intset-entries",0)) {
addReplyBulkCString(c,"set-max-intset-entries");
addReplyBulkLongLong(c,server.set_max_intset_entries);
matches++;
}
setDeferredMultiBulkLength(c,replylen,matches*2);
}

View File

@@ -110,6 +110,10 @@ void execCommand(redisClient *c) {
c->argc = c->mstate.commands[j].argc;
c->argv = c->mstate.commands[j].argv;
call(c,c->mstate.commands[j].cmd);
/* Commands may alter argc/argv, restore mstate. */
c->mstate.commands[j].argc = c->argc;
c->mstate.commands[j].argv = c->argv;
}
c->argv = orig_argv;
c->argc = orig_argc;

View File

@@ -498,7 +498,6 @@ void freeClient(redisClient *c) {
/* Case 2: we lost the connection with the master. */
if (c->flags & REDIS_MASTER) {
server.master = NULL;
/* FIXME */
server.replstate = REDIS_REPL_CONNECT;
/* Since we lost the connection with the master, we should also
* close the connection with all our slaves if we have any, so

View File

@@ -143,7 +143,7 @@ static void randomizeClientKey(client c) {
for (i = 0; i < c->randlen; i++) {
r = random() % config.randomkeys_keyspacelen;
snprintf(buf,sizeof(buf),"%012lu",r);
snprintf(buf,sizeof(buf),"%012zu",r);
memcpy(c->randptr[i],buf,12);
}
}

View File

@@ -516,7 +516,7 @@ void updateLRUClock(void) {
}
int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
int j, loops = server.cronloops++;
int j, loops = server.cronloops;
REDIS_NOTUSED(eventLoop);
REDIS_NOTUSED(id);
REDIS_NOTUSED(clientData);
@@ -645,6 +645,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
* to detect transfer failures. */
if (!(loops % 10)) replicationCron();
server.cronloops++;
return 100;
}
@@ -851,10 +852,13 @@ void initServer() {
createSharedObjects();
server.el = aeCreateEventLoop();
server.db = zmalloc(sizeof(redisDb)*server.dbnum);
server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr);
if (server.ipfd == ANET_ERR) {
redisLog(REDIS_WARNING, "Opening port: %s", server.neterr);
exit(1);
if (server.port != 0) {
server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr);
if (server.ipfd == ANET_ERR) {
redisLog(REDIS_WARNING, "Opening port: %s", server.neterr);
exit(1);
}
}
if (server.unixsocket != NULL) {
unlink(server.unixsocket); /* don't care if this fails */
@@ -912,6 +916,7 @@ void initServer() {
}
if (server.vm_enabled) vmInit();
srand(time(NULL)^getpid());
}
/* Populates the Redis Command Table starting from the hard coded list
@@ -1456,6 +1461,7 @@ void freeMemoryIfNeeded(void) {
/* Finally remove the selected key. */
if (bestkey) {
robj *keyobj = createStringObject(bestkey,sdslen(bestkey));
propagateExpire(db,keyobj);
dbDelete(db,keyobj);
server.stat_evictedkeys++;
decrRefCount(keyobj);

View File

@@ -328,6 +328,12 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
buf+1);
replicationAbortSyncTransfer();
return;
} else if (buf[0] == '\0') {
/* At this stage just a newline works as a PING in order to take
* the connection live. So we refresh our last interaction
* timestamp. */
server.repl_transfer_lastio = time(NULL);
return;
} else if (buf[0] != '$') {
redisLog(REDIS_WARNING,"Bad protocol from MASTER, the first byte is not '$', are you sure the host and port are right?");
replicationAbortSyncTransfer();
@@ -488,17 +494,26 @@ void slaveofCommand(redisClient *c) {
/* --------------------------- REPLICATION CRON ---------------------------- */
#define REDIS_REPL_TRANSFER_TIMEOUT 60
#define REDIS_REPL_TIMEOUT 60
#define REDIS_REPL_PING_SLAVE_PERIOD 10
void replicationCron(void) {
/* Bulk transfer I/O timeout? */
if (server.masterhost && server.replstate == REDIS_REPL_TRANSFER &&
(time(NULL)-server.repl_transfer_lastio) > REDIS_REPL_TRANSFER_TIMEOUT)
(time(NULL)-server.repl_transfer_lastio) > REDIS_REPL_TIMEOUT)
{
redisLog(REDIS_WARNING,"Timeout receiving bulk data from MASTER...");
replicationAbortSyncTransfer();
}
/* Timed out master when we are an already connected slave? */
if (server.masterhost && server.replstate == REDIS_REPL_CONNECTED &&
(time(NULL)-server.master->lastinteraction) > REDIS_REPL_TIMEOUT)
{
redisLog(REDIS_WARNING,"MASTER time out: no data nor PING received...");
freeClient(server.master);
}
/* Check if we should connect to a MASTER */
if (server.replstate == REDIS_REPL_CONNECT) {
redisLog(REDIS_NOTICE,"Connecting to MASTER...");
@@ -507,4 +522,35 @@ void replicationCron(void) {
if (server.appendonly) rewriteAppendOnlyFileBackground();
}
}
/* If we have attached slaves, PING them from time to time.
* So slaves can implement an explicit timeout to masters, and will
* be able to detect a link disconnection even if the TCP connection
* will not actually go down. */
if (!(server.cronloops % (REDIS_REPL_PING_SLAVE_PERIOD*10))) {
listIter li;
listNode *ln;
listRewind(server.slaves,&li);
while((ln = listNext(&li))) {
redisClient *slave = ln->value;
/* Don't ping slaves that are in the middle of a bulk transfer
* with the master for first synchronization. */
if (slave->replstate == REDIS_REPL_SEND_BULK) continue;
if (slave->replstate == REDIS_REPL_ONLINE) {
/* If the slave is online send a normal ping */
addReplySds(slave,sdsnew("PING\r\n"));
} else {
/* Otherwise we are in the pre-synchronization stage.
* Just a newline will do the work of refreshing the
* connection last interaction time, and at the same time
* we'll be sure that being a single char there are no
* short-write problems. */
if (write(slave->fd, "\n", 1) == -1) {
/* Don't worry, it's just a ping. */
}
}
}
}
}

View File

@@ -826,7 +826,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
addReplyBulk(receiver,ele);
return 1;
} else {
/* BRPOPLPUSH */
/* BRPOPLPUSH, note that receiver->db is always equal to c->db. */
dstobj = lookupKeyWrite(receiver->db,dstkey);
if (dstobj && checkType(receiver,dstobj,REDIS_LIST)) {
decrRefCount(dstkey);
@@ -941,7 +941,7 @@ void brpoplpushCommand(redisClient *c) {
/* Blocking against an empty list in a multi state
* returns immediately. */
addReply(c, shared.nullmultibulk);
addReply(c, shared.nullbulk);
} else {
/* The list is empty and the client blocks. */
blockForKeys(c, c->argv + 1, 1, timeout, c->argv[2]);

View File

@@ -334,12 +334,25 @@ void spopCommand(redisClient *c) {
encoding = setTypeRandomElement(set,&ele,&llele);
if (encoding == REDIS_ENCODING_INTSET) {
addReplyBulkLongLong(c,llele);
ele = createStringObjectFromLongLong(llele);
set->ptr = intsetRemove(set->ptr,llele,NULL);
} else {
addReplyBulk(c,ele);
incrRefCount(ele);
setTypeRemove(set,ele);
}
/* Change argv to replicate as SREM */
c->argc = 3;
c->argv = zrealloc(c->argv,sizeof(robj*)*(c->argc));
/* Overwrite SREM with SPOP (same length) */
redisAssert(sdslen(c->argv[0]->ptr) == 4);
memcpy(c->argv[0]->ptr, "SREM", 4);
/* Popped element already has incremented refcount */
c->argv[2] = ele;
addReplyBulk(c,ele);
if (setTypeSize(set) == 0) dbDelete(c->db,c->argv[1]);
touchWatchedKey(c->db,c->argv[1]);
server.dirty++;

View File

@@ -1 +1 @@
#define REDIS_VERSION "2.1.11"
#define REDIS_VERSION "2.2.1"

View File

@@ -262,7 +262,7 @@ size_t zmalloc_get_rss(void) {
return t_info.resident_size;
}
#else
float zmalloc_get_rss(void) {
size_t zmalloc_get_rss(void) {
/* If we can't get the RSS in an OS-specific way for this system just
* return the memory usage we estimated in zmalloc()..
*

View File

@@ -44,9 +44,14 @@ proc assert_type {type key} {
assert_equal $type [r type $key]
}
# Test if TERM looks like to support colors
proc color_term {} {
expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
}
# This is called before starting the test
proc announce_test {s} {
if {[info exists ::env(TERM)] && [string match $::env(TERM) xterm]} {
if {[color_term]} {
puts -nonewline "$s\033\[0K"
flush stdout
set ::backward_count [string length $s]
@@ -55,7 +60,7 @@ proc announce_test {s} {
# This is called after the test finished
proc colored_dot {tags passed} {
if {[info exists ::env(TERM)] && [string match $::env(TERM) xterm]} {
if {[color_term]} {
# Go backward and delete what announc_test function printed.
puts -nonewline "\033\[${::backward_count}D\033\[0K\033\[J"

View File

@@ -174,6 +174,13 @@ start_server {tags {"other"}} {
set _ $err
} {*ERR MULTI*}
test {MULTI where commands alter argc/argv} {
r sadd myset a
r multi
r spop myset
list [r exec] [r exists myset]
} {a 0}
test {WATCH inside MULTI is not allowed} {
set err {}
r multi

13
utils/mktarball.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
if [ "$1" = "" ]
then
echo "Usage: mktarball.sh <git tag, branch or commit>"
echo "Example: mktarball.sh 2.2-rc4"
exit 1
fi
PREFIX="redis-${1}/"
TARBALL="/tmp/redis-${1}.tar.gz"
git archive --format=tar --prefix=$PREFIX $1 | gzip -c > $TARBALL
echo "File created: $TARBALL"