Skip to content
This repository

zinterstore fails when mixing sets and sorted sets #516

Closed
atanivist opened this Issue May 22, 2012 · 2 comments

2 participants

atanivist Salvatore Sanfilippo
atanivist

I have two sets and a single sorted set and I'm trying to use zinterstore to get the scored intersection of all three. The operation is failing with my production data but succeeding if I substitute a test sorted set it works in some cases but not all and I'm stumped about why.

To setup the test, add three entries to set "one", four entries to set "two" - including a signle entry that exists in set "one", and four entries in the sorted set - including that same single entry from set "one"

sadd one 100 101 102 103 
sadd two 100 200 201 202
zadd three 1 500 1 501 1 502 1 503 1 100

Now if you run

zinterstore to_here 3 one two three WEIGHTS 0 0 1

Nothing is found to intersect.

Create a new sort set "four":

zadd four 1 600 1 100 

zinterstore to_here 3 one two four WEIGHTS 0 0 1

There is an intersection on the entry 100!

My production data isn't so simple but I'm seeing the same result, some intersections appear to work, at least in part, but others fail completely.

This happens on redis versions 2.4.13 and the latest 2.6 RC.

Josiah Carlson kindly tested this and found that it behaves correctly in earlier versions of redis:

Testing against Redis 2.4.1, 2.4.7, 2.4.10 your intersection works for me.
Testing against Redis 2.4.13 however, fails.

Salvatore Sanfilippo
Owner
antirez commented May 23, 2012

Thanks, investigating right now.

Salvatore Sanfilippo antirez referenced this issue from a commit May 23, 2012
Salvatore Sanfilippo Fixed issue #516 (ZINTERSTORE mixing sets and zsets).
Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
b0a2093
Salvatore Sanfilippo antirez referenced this issue from a commit May 23, 2012
Salvatore Sanfilippo Fixed issue #516 (ZINTERSTORE mixing sets and zsets).
Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
4dada1b
Salvatore Sanfilippo antirez referenced this issue from a commit May 23, 2012
Salvatore Sanfilippo Fixed issue #516 (ZINTERSTORE mixing sets and zsets).
Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
348ee1a
Salvatore Sanfilippo
Owner
antirez commented May 23, 2012

Fixed in 2.4.14, already available for download. Thanks.

Salvatore Sanfilippo antirez closed this June 04, 2012
Steffen Müller tsee referenced this issue from a commit in tsee/redis May 23, 2012
Salvatore Sanfilippo Fixed issue #516 (ZINTERSTORE mixing sets and zsets).
Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
74ed594
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.