Skip to content

ZUNIONSTORE stores less than input keys content under certain conditions #1240

@hermann-kosselowski

Description

@hermann-kosselowski

Hi.

We're using Redis (among other things) for a sorted id list.
In the around 700 sorted sets ranging from 100 to 10000 members we noticed problems with missing members in 21 of them (1 to 1300+ missing members).

Steps to reproduce (tested with Redis 2.6.14)

  • create sorted set with 1028 members and scores (zetAdditional)
  • created set with 1028 members (our test case has 772 members that are also in zetAdditional)
  • ZINTERSTORE zetIntermediate 2 setKey zetAdditional WEIGHTS 0 1
  • ZUNIONSTORE zetFinal 2 setKey zetIntermediate WEIGHTS 0 1

Expected Result:
ZCARD zetFinal -> 1028

Actual Result
ZCARD zetFinal -> 1027

Running the same ZUNIONSTORE again will return the correct value and fix zetFinal.

I've created a paste with a test file containing the Redis commands to reproduce it:
http://pastebin.com/TaFkkYkY

If you download it you need to add a new line after the last command since pastebin removed that. Also be warned that it runs FLUSHDB at first.

Run with:

cat redis-commands.txt | redis-cli --pipe

and then

redis-cli ZCARD zetFinal

Which should return 1027 (one member missing).

I tried to strip down the test case to the minimum but noticed that if zetAdditional is smaller than setKey the bug won't occur. The same if going below 1028 members.

Here's the output of INFO from my Redis test instance:
http://pastebin.com/QFn6S4ri

If there is anything else needed, don't hesitate to ask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions