diff --git a/src/t_list.c b/src/t_list.c index adb0c409..7c1b848a 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -822,7 +822,6 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) { /* This should remove the first element of the "clients" list. */ unblockClientWaitingData(receiver); - redisAssert(ln != listFirst(clients)); if (dstkey == NULL) { /* BRPOP/BLPOP */ diff --git a/src/t_set.c b/src/t_set.c index b221e2e9..be083c8b 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -437,6 +437,7 @@ void sinterGenericCommand(redisClient *c, robj **setkeys, unsigned long setnum, si = setTypeInitIterator(sets[0]); while((encoding = setTypeNext(si,&eleobj,&intobj)) != -1) { for (j = 1; j < setnum; j++) { + if (sets[j] == sets[0]) continue; if (encoding == REDIS_ENCODING_INTSET) { /* intset with intset is simple... and fast */ if (sets[j]->encoding == REDIS_ENCODING_INTSET && diff --git a/src/t_zset.c b/src/t_zset.c index 3e76ebd1..1c55cb97 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1521,7 +1521,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { score = src[0].weight * zval.score; for (j = 1; j < setnum; j++) { - if (zuiFind(&src[j],&zval,&value)) { + /* It is not safe to access the hash we zset we are + * iterating, so explicitly check for equal object. */ + if (src[j].subject == src[0].subject) { + value = zval.score*src[j].weight; + zunionInterAggregate(&score,value,aggregate); + } else if (zuiFind(&src[j],&zval,&value)) { value *= src[j].weight; zunionInterAggregate(&score,value,aggregate); } else { @@ -1561,7 +1566,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { /* Because the inputs are sorted by size, it's only possible * for sets at larger indices to hold this element. */ for (j = (i+1); j < setnum; j++) { - if (zuiFind(&src[j],&zval,&value)) { + /* It is not safe to access the hash we zset we are + * iterating, so explicitly check for equal object. */ + if(src[j].subject == src[i].subject) { + value = zval.score*src[j].weight; + zunionInterAggregate(&score,value,aggregate); + } else if (zuiFind(&src[j],&zval,&value)) { value *= src[j].weight; zunionInterAggregate(&score,value,aggregate); } diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index 6ca5a6dd..7be4df4b 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -27,6 +27,8 @@ start_server {tags {"repl"}} { test {MASTER and SLAVE consistency with expire} { createComplexDataset r 50000 useexpire after 4000 ;# Make sure everything expired before taking the digest + r keys * ;# Force DEL syntesizing to slave + after 1000 ;# Wait another second. Now everything should be file. if {[r debug digest] ne [r -1 debug digest]} { set csv1 [csvdump r] set csv2 [csvdump {r -1}] diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index 4fa7af1b..37668cfe 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -460,6 +460,13 @@ start_server {tags {"zset"}} { basics ziplist basics skiplist + test {ZINTERSTORE regression with two sets, intset+hashtable} { + r del seta setb setc + r sadd set1 a + r sadd set2 10 + r zinterstore set3 2 set1 set2 + } {0} + proc stressers {encoding} { if {$encoding == "ziplist"} { # Little extra to allow proper fuzzing in the sorting stresser