Skip to content

Commit

Permalink
improve backoff interval and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan.rieckhof committed Nov 14, 2024
1 parent 8ecf3e0 commit 06c105a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions maintenance/failover/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ func (a *ActivePassive) Run(ctx context.Context) error {
if err != nil {
logger.Warn().Err(err).Msg("failed to refresh the redis lock; attempting to reacquire lock")

// Attempt to reacquire the lock immediately but try only once
// Attempt to reacquire the lock immediately with a short backoff interval and limited retries
var errReacquire error

lock, errReacquire = a.locker.Obtain(ctx, lockName, a.timeToFailover, &redislock.Options{
RetryStrategy: redislock.LimitRetry(redislock.LinearBackoff(50*time.Millisecond), 2),
RetryStrategy: redislock.LimitRetry(redislock.LinearBackoff(100*time.Millisecond), 2),
})
if errReacquire == nil {
// Successfully reacquired the lock, remain active
Expand Down

0 comments on commit 06c105a

Please sign in to comment.