From cdf5bd0500a4f99f35b0cfd7b10fe7cdf7599d39 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 10 Feb 2021 19:21:42 +0200 Subject: [PATCH] return annotated xerrors where appropriate --- chain/store/splitstore/lmdb_util.go | 10 ++++++++-- chain/store/splitstore/snoop.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/chain/store/splitstore/lmdb_util.go b/chain/store/splitstore/lmdb_util.go index 2f0cb706c..91920bca3 100644 --- a/chain/store/splitstore/lmdb_util.go +++ b/chain/store/splitstore/lmdb_util.go @@ -4,18 +4,24 @@ import ( "math/rand" "time" + "golang.org/x/xerrors" + "github.com/ledgerwatch/lmdb-go/lmdb" ) func withMaxReadersRetry(f func() error) error { retry: err := f() - if lmdb.IsErrno(err, lmdb.ReadersFull) { + if err != nil && lmdb.IsErrno(err, lmdb.ReadersFull) { dt := time.Microsecond + time.Duration(rand.Intn(int(time.Millisecond))) log.Debugf("MDB_READERS_FULL; retrying operation in %s", dt) time.Sleep(dt) goto retry } - return err + if err != nil { + return xerrors.Errorf("error performing lmdb operation: %w", err) + } + + return nil } diff --git a/chain/store/splitstore/snoop.go b/chain/store/splitstore/snoop.go index 7b07b7e21..f823a45ed 100644 --- a/chain/store/splitstore/snoop.go +++ b/chain/store/splitstore/snoop.go @@ -68,7 +68,7 @@ func NewTrackingStore(path string) (TrackingStore, error) { }) if err != nil { - return nil, err + return nil, xerrors.Errorf("error creating tracking store: %w", err) } return s, nil