etcd
etcd copied to clipboard
server: update defrag logic to use bolt.Compact()
They are pretty much same implementation. Iterate over buckets, iterate over keys and copy from old db to new db.
One difference is that etcd implementation was setting FillPercent to 0.9 while boltdb implementation sets it to 1.0. After this change the defrag duration on my database dropped from 10.5 to 9 seconds probably because of this change.
The other difference is that boltdb implementation also handles nested buckets. Etcd does not have any nested buckets at the moment but it's nice to have that covered.
With this change, defrag limit changes from 10,000 keys to 10 MB data because bolt.Compact() API wants byte size.