From 0aed6a952a0acf5a02ec4b588031ec3dc231a68c Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 10 Mar 2011 16:39:19 +0100 Subject: [PATCH 1/3] fixed diskstore race condition --- src/dscache.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dscache.c b/src/dscache.c index 2dbc1134d..cbe9bb016 100644 --- a/src/dscache.c +++ b/src/dscache.c @@ -890,8 +890,16 @@ int waitForSwappedKey(redisClient *c, robj *key) { listAddNodeTail(l,c); /* Are we already loading the key from disk? If not create a job */ - if (de == NULL) - cacheScheduleIO(c->db,key,REDIS_IO_LOAD); + if (de == NULL) { + int flags = cacheScheduleIOGetFlags(c->db,key); + + /* It is possible that even if there are no clients waiting for + * a load operation, still we have a load operation in progress. + * For instance think to a client performing a GET and then + * closing the connection */ + if ((flags & (REDIS_IO_LOAD|REDIS_IO_LOADINPROG)) == 0) + cacheScheduleIO(c->db,key,REDIS_IO_LOAD); + } return 1; } From 38a154a9a6244826a8cb536347a60749cef2ee4a Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 19 May 2011 17:58:29 +0200 Subject: [PATCH 2/3] Fix for ZUNIONSTORE bug when there is an empty set among input sets. Regression test added. --- src/t_zset.c | 2 +- tests/unit/type/zset.tcl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/t_zset.c b/src/t_zset.c index 1c55cb97a..19aac3d50 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1550,7 +1550,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { } } else if (op == REDIS_OP_UNION) { for (i = 0; i < setnum; i++) { - if (zuiLength(&src[0]) == 0) + if (zuiLength(&src[i]) == 0) continue; while (zuiNext(&src[i],&zval)) { diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index 37668cfe2..761cac49c 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -353,6 +353,14 @@ start_server {tags {"zset"}} { assert_equal 0 [r exists dst_key] } + test "ZUNIONSTORE with empty set - $encoding" { + r del zseta zsetb + r zadd zseta 1 a + r zadd zseta 2 b + r zunionstore zsetc 2 zseta zsetb + r zrange zsetc 0 -1 withscores + } {a 1 b 2} + test "ZUNIONSTORE basics - $encoding" { r del zseta zsetb zsetc r zadd zseta 1 a From b3bc4452d26304c620fbca5a20db4b695eb8229c Mon Sep 17 00:00:00 2001 From: Damian Janowski Date: Fri, 24 Jun 2011 13:56:06 -0300 Subject: [PATCH 3/3] Avoid bug reports when Tcl is not installed. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index e08c69876..81bd24593 100644 --- a/src/Makefile +++ b/src/Makefile @@ -178,7 +178,7 @@ dep: $(CC) -MM *.c -I ../deps/hiredis -I ../deps/linenoise test: redis-server - (cd ..; tclsh8.5 tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}") + @(cd ..; (which tclsh >/dev/null && tclsh tests/test_helper.tcl --tags "${TAGS}" --file "${FILE}") || echo "You need to install Tcl in order to run tests.") bench: ./redis-benchmark