When doing an iteration of keys in Badger, I am often running into errors such as these:
E0122 13:54:13.879347 12645] failed: Invalid value pointer offset: 13172995 greater than current offset: 0
E0123 03:13:02.601610 12645] failed: Invalid value pointer offset: 16782105 greater than current offset: 0
E0124 18:54:07.499596 12645] failed: Invalid value pointer offset: 34597965 greater than current offset: 0
Here is the related code:
err := db.View(func(txn *badger.Txn) error {
opts := badger.DefaultIteratorOptions
opts.Reverse = true
it := txn.NewIterator(opts)
for it.Rewind(); it.Valid() && count > 0; it.Next() {
item := it.Item()
v, err := item.Value() // error happens here
if err != nil {
return err
}
art := &Article{}
err = proto.Unmarshal(v, art)
if err != nil {
return err
}
articles = append(articles, art)
count--
}
return nil
})
The error happens when retrieving value from the item. Any pointers to what might be causing the problem?
Thanks!