Skip to content

The implementation of randomKey command may be slow and not safe #230

@mzygQAQ

Description

@mzygQAQ

titan/db/kv.go

Line 215 in 97868f5

for iter.Valid() && iter.Key().HasPrefix(prefix) {

  1. After we generate a ranom metakey for seek, we iterator the whole keyspace and load it's all key to the memory under extreme conditions which is so slow and may cause OOM.
  2. When we iterate the keyspace , we never judge the expire time of the key, it may has expired already, so RandomKey may return a expired key, and user will get nil when use this key to lookup value.

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