diff --git a/wal/wal.go b/wal/wal.go index 0e95ba2a..80a28248 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -261,6 +261,8 @@ func (w *WAL) Repair(err error) error { // But that's not generally applicable if the records have any kind of causality. // Maybe as an extra mode in the future if mid-WAL corruptions become // a frequent concern. + err = errors.Cause(err) // So that we can pick up errors even if wrapped. + cerr, ok := err.(*CorruptionErr) if !ok { return errors.New("cannot handle error") diff --git a/wal/wal_test.go b/wal/wal_test.go index d1b724c7..26ee8663 100644 --- a/wal/wal_test.go +++ b/wal/wal_test.go @@ -23,6 +23,7 @@ import ( "os" "testing" + "github.com/pkg/errors" "github.com/prometheus/tsdb/testutil" ) @@ -286,8 +287,8 @@ func TestWAL_Repair(t *testing.T) { for r.Next() { } testutil.NotOk(t, r.Err()) - testutil.Ok(t, w.Repair(r.Err())) + testutil.Ok(t, w.Repair(errors.Wrap(r.Err(), "err"))) // See https://github.com/prometheus/prometheus/issues/4603 sr, err = NewSegmentsReader(dir) testutil.Ok(t, err)