return annotated xerrors where appropriate
This commit is contained in:
parent
ea05fd9d86
commit
cdf5bd0500
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user