return annotated xerrors where appropriate
This commit is contained in:
parent
ea05fd9d86
commit
cdf5bd0500
@ -4,18 +4,24 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/ledgerwatch/lmdb-go/lmdb"
|
"github.com/ledgerwatch/lmdb-go/lmdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func withMaxReadersRetry(f func() error) error {
|
func withMaxReadersRetry(f func() error) error {
|
||||||
retry:
|
retry:
|
||||||
err := f()
|
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)))
|
dt := time.Microsecond + time.Duration(rand.Intn(int(time.Millisecond)))
|
||||||
log.Debugf("MDB_READERS_FULL; retrying operation in %s", dt)
|
log.Debugf("MDB_READERS_FULL; retrying operation in %s", dt)
|
||||||
time.Sleep(dt)
|
time.Sleep(dt)
|
||||||
goto retry
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, xerrors.Errorf("error creating tracking store: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user