lotus/chain/store/splitstore/lmdb_util.go
2021-03-05 14:46:17 +02:00

22 lines
389 B
Go

package splitstore
import (
"math/rand"
"time"
"github.com/ledgerwatch/lmdb-go/lmdb"
)
func withMaxReadersRetry(f func() error) error {
retry:
err := f()
if 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
}