zinterstore fails when mixing sets and sorted sets #516

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

Comments

Projects
None yet
2 participants
@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.

@antirez

This comment has been minimized.

Show comment
Hide comment
@antirez

antirez May 23, 2012

Owner

Thanks, investigating right now.

Owner

antirez commented May 23, 2012

Thanks, investigating right now.

antirez added a commit that referenced this issue May 23, 2012

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.

antirez added a commit that referenced this issue May 23, 2012

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.

antirez added a commit that referenced this issue May 23, 2012

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.
@antirez

This comment has been minimized.

Show comment
Hide comment
@antirez

antirez May 23, 2012

Owner

Fixed in 2.4.14, already available for download. Thanks.

Owner

antirez commented May 23, 2012

Fixed in 2.4.14, already available for download. Thanks.

@antirez antirez closed this Jun 5, 2012

tsee added a commit to tsee/redis that referenced this issue Jul 31, 2012

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.

Hailei pushed a commit to Hailei/redis that referenced this issue Aug 29, 2014

Merge pull request #516 from HeartSaVioR/fix-timing-issues-with-monit…
…or-test

Fix ControlCommandsTest to don't hang from monitor test because of timing issue

JackieXie168 pushed a commit to JackieXie168/redis that referenced this issue Aug 29, 2016

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment