Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iterators): Do not return error on missing vlog #1602

Merged
merged 3 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion iterator.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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