lotus/chain/store/splitstore/lmdb_util.go

22 lines
389 B
Go
Raw Normal View History

2021-02-01 12:27:20 +00:00
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)))
2021-02-01 12:31:31 +00:00
log.Debugf("MDB_READERS_FULL; retrying operation in %s", dt)
2021-02-01 12:27:20 +00:00
time.Sleep(dt)
goto retry
}
return err
}