Skip to content

Commit

Permalink
cache: log down redis ping interval
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Feb 26, 2022
1 parent 08c4d86 commit ea2d0e8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dispatcher/pkg/cache/redis_cache/redis_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ func (r *RedisCache) disableClient() {
r.logger().Warn("redis temporarily disabled")
go func() {
const maxBackoff = time.Second * 30
backoff := time.Duration(0)
backoff := time.Millisecond * 100
for {
if backoff >= maxBackoff {
backoff = maxBackoff
} else {
backoff += time.Duration(rand.Intn(1000))*time.Millisecond + time.Second
}
time.Sleep(backoff)
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
err := r.Client.Ping(ctx).Err()
cancel()
if err != nil {
r.logger().Warn("redis ping failed", zap.Error(err))
if backoff >= maxBackoff {
backoff = maxBackoff
} else {
backoff += time.Duration(rand.Intn(1000))*time.Millisecond + time.Second
}
r.logger().Warn("redis ping failed", zap.Error(err), zap.Duration("next_ping", backoff))
continue
}
atomic.StoreUint32(&r.clientDisabled, 0)
Expand Down

0 comments on commit ea2d0e8

Please # to comment.