titan icon indicating copy to clipboard operation
titan copied to clipboard

The implementation of randomKey command may be slow and not safe

Open mzygQAQ opened this issue 3 years ago • 0 comments

https://github.com/distributedio/titan/blob/97868f5d24e0c13621658fbcb712064fec59e8be/db/kv.go#L215

  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.

mzygQAQ avatar Apr 21 '22 12:04 mzygQAQ