[Badger] Invalid value pointer offset

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!

Hey @sgarg

Is it possible for you to share a complete reproducible example?

I have tried to come up with a simple reproducible scenario. But so far, I am not able to do so. It seems to me that this issue is related to the writes which are still in memory. Any pointers to why that might be problematic while using an iterator? Do the keys have to be monotonically increasing?

Can you please share more details about your workload and also share the code which shows how you use badger in your programn

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.