Skip to content

Commit

Permalink
chore(iterators): Do not return error on missing vlog (#1602)
Browse files Browse the repository at this point in the history
Add debugging information in yieldItemValue function to find the root cause
of missing vlog files error.

Note: This commit should be reverted once the issue has been resolved.
  • Loading branch information
Ibrahim Jarif committed Nov 25, 2020
1 parent 925e15b commit feb1f5f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
22 changes: 21 additions & 1 deletion iterator.go
Expand Up @@ -170,8 +170,28 @@ func (item *Item) yieldItemValue() ([]byte, func(), error) {
if err != nil {
db.opt.Logger.Errorf("Unable to read: Key: %v, Version : %v, meta: %v, userMeta: %v"+
" Error: %v", key, item.version, item.meta, item.userMeta, err)
txn := db.NewTransaction(false)
defer txn.Discard()

iopt := DefaultIteratorOptions
iopt.AllVersions = true
iopt.InternalAccess = true
iopt.PrefetchValues = false

it := txn.NewKeyIterator(item.Key(), iopt)
defer it.Close()
for it.Rewind(); it.Valid(); it.Next() {
item := it.Item()
var vp valuePointer
if item.meta&bitValuePointer > 0 {
vp.Decode(item.vptr)
}
db.opt.Logger.Errorf("Key: %v, Version : %v, meta: %v, userMeta: %v valuePointer: %+v",
item.Key(), item.version, item.meta, item.userMeta, vp)
}
}
return result, cb, err
// Don't return error if we cannot read the value. Just log the error.
return result, cb, nil
}

func runCallback(cb func()) {
Expand Down
12 changes: 8 additions & 4 deletions value_test.go
Expand Up @@ -1084,10 +1084,14 @@ func TestValueEntryChecksum(t *testing.T) {
entry, err := txn.Get(k)
require.NoError(t, err)

x, err := entry.ValueCopy(nil)
require.Error(t, err)
require.Contains(t, err.Error(), "ErrEOF")
require.Nil(t, x)
// TODO(ibrahim): This test is broken since we're not returning errors
// in case we cannot read the values. This is incorrect behavior but
// we're doing this to debug an issue where the values are being read
// from old vlog files.
_, _ = entry.ValueCopy(nil)
// require.Error(t, err)
// require.Contains(t, err.Error(), "ErrEOF")
// require.Nil(t, x)

require.NoError(t, db.Close())
})
Expand Down

0 comments on commit feb1f5f

Please sign in to comment.