mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-06 18:00:25 +02:00
kvdb/sqlbase: fix params used in randRetryDelay
This commit is contained in:
parent
f7cb44382e
commit
08f4940e88
@ -234,7 +234,9 @@ func (db *db) Update(f func(tx walletdb.ReadWriteTx) error,
|
|||||||
|
|
||||||
// randRetryDelay returns a random retry delay between -50% and +50% of the
|
// randRetryDelay returns a random retry delay between -50% and +50% of the
|
||||||
// configured delay that is doubled for each attempt and capped at a max value.
|
// configured delay that is doubled for each attempt and capped at a max value.
|
||||||
func randRetryDelay(initialRetryDelay, maxRetryDelay, attempt int) time.Duration {
|
func randRetryDelay(initialRetryDelay, maxRetryDelay time.Duration,
|
||||||
|
attempt int) time.Duration {
|
||||||
|
|
||||||
halfDelay := initialRetryDelay / 2
|
halfDelay := initialRetryDelay / 2
|
||||||
randDelay := prand.Int63n(int64(initialRetryDelay)) //nolint:gosec
|
randDelay := prand.Int63n(int64(initialRetryDelay)) //nolint:gosec
|
||||||
|
|
||||||
@ -273,8 +275,8 @@ func (db *db) executeTransaction(f func(tx walletdb.ReadWriteTx) error,
|
|||||||
// should abort the retries.
|
// should abort the retries.
|
||||||
waitBeforeRetry := func(attemptNumber int) bool {
|
waitBeforeRetry := func(attemptNumber int) bool {
|
||||||
retryDelay := randRetryDelay(
|
retryDelay := randRetryDelay(
|
||||||
attemptNumber, DefaultInitialRetryDelay,
|
DefaultInitialRetryDelay, DefaultMaxRetryDelay,
|
||||||
DefaultMaxRetryDelay,
|
attemptNumber,
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debugf("Retrying transaction due to tx serialization "+
|
log.Debugf("Retrying transaction due to tx serialization "+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user