Description
In my opinion code such as this is incorrect:
Lines 105 to 112 in 2cdd828
Reasoning:
https://pkg.go.dev/github.com/dgraph-io/badger/v3#Item.Key:
Key is only valid as long as item is valid, or transaction is valid. If you need to use it outside its validity, please use KeyCopy.
https://pkg.go.dev/github.com/dgraph-io/badger/v3#Iterator.Item:
Item returns pointer to the current key-value pair. This item is only valid until it.Next() gets called.
In my opinion in this situation the item is only valid until the next iteration therefore key is illegaly reused. KeyCopy
should be used instead. It is possible that txn.Delete(...)
will remove other data. I imagine this is the case in other places in the code as well.