[using leveldb problem] what is the different between db->get (key) and db->NewIterator(), iter->seek(key) ?

35 views
Skip to first unread message

pengl...@gmail.com

unread,
Mar 20, 2018, 9:37:05 AM3/20/18
to leveldb
Ceph(https://github.com/ceph/ceph)  Project using leveldb to store monitor data. 

Recently I have found that my store db is getting larger and larger to be 60GB size.

After I send command "compactrange(NULL, NULL)", the size of the store db is only 100MB.

In the ceph documents, it has claims that the monitor store can be getting large but do not explain why.

I then review the ceph code ,and find that ceph monitor write keys increasing one at a time. After increasing 750 keys, it reclaims 250 older keys and

send a compactrange(from, to) command asynchronously.

 In ceph monitor code ,when it get one key, it use db->NewIterator , iter->seek(key) method, not db->get(key) function. I can not understand why not using db->get(key), it is simple and easy to understand.

I tried to replace db->NewIterator with db->get(key) but sometimes I got a deleted  value. It's just surprising!

Can anyone explain the different between db->NewIterator and db->get(key) when getting a key value?




Reply all
Reply to author
Forward
Message has been deleted
0 new messages