Skip to content

[BUG] Hang and OOM in srandmember #635

@yype

Description

@yype

Describe the bug

The following commands when used together could hang the keydb-server, making it unable to reply to any clients and increasingly consuming memory.

To reproduce

sadd a xxx
srandmember a -1428663252545913856

Expected behavior

An error should be returned instead of hanging. This could avoid DoS and server OOM.

Additional information

  1. This is likely due to improper checks for the range. When issued these two commands, the memory consumption of keydb increases over time drastically and is likely to cause an OOM of the server.
  2. A similar bug was also found in redis reported here: [CRASH] OOM Crash for srandmember redis/redis#11668, where redis crashes with an OOM panic before consuming lots of memory. The fix is to implement proper checks.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions