diff --git a/pkg/config/redis.go b/pkg/config/redis.go index 201c22a9..ad8b31a6 100644 --- a/pkg/config/redis.go +++ b/pkg/config/redis.go @@ -92,9 +92,9 @@ func dialWithLogging(dialer ctxDialerFunc, logger *logging.Logger) ctxDialerFunc } }, OnSuccess: func(elapsed time.Duration, attempt uint64, _ error) { - if attempt > 0 { + if attempt > 1 { logger.Infow("Reconnected to Redis", - zap.Duration("after", elapsed), zap.Uint64("attempts", attempt+1)) + zap.Duration("after", elapsed), zap.Uint64("attempts", attempt)) } }, }, diff --git a/pkg/icingadb/db.go b/pkg/icingadb/db.go index a5bccca6..4c575e3b 100644 --- a/pkg/icingadb/db.go +++ b/pkg/icingadb/db.go @@ -680,10 +680,10 @@ func (db *DB) getDefaultRetrySettings() retry.Settings { } }, OnSuccess: func(elapsed time.Duration, attempt uint64, lastErr error) { - if attempt > 0 { + if attempt > 1 { db.logger.Infow("Query retried successfully after error", zap.Duration("after", elapsed), - zap.Uint64("attempts", attempt+1), + zap.Uint64("attempts", attempt), zap.NamedError("recovered_error", lastErr)) } }, diff --git a/pkg/icingadb/driver.go b/pkg/icingadb/driver.go index 0f3453db..ac5af7e1 100644 --- a/pkg/icingadb/driver.go +++ b/pkg/icingadb/driver.go @@ -66,9 +66,9 @@ func (c RetryConnector) Connect(ctx context.Context) (driver.Conn, error) { OnSuccess: func(elapsed time.Duration, attempt uint64, _ error) { telemetry.UpdateCurrentDbConnErr(nil) - if attempt > 0 { + if attempt > 1 { c.logger.Infow("Reconnected to database", - zap.Duration("after", elapsed), zap.Uint64("attempts", attempt+1)) + zap.Duration("after", elapsed), zap.Uint64("attempts", attempt)) } }, }, diff --git a/pkg/icingadb/ha.go b/pkg/icingadb/ha.go index a6355f31..68a2a68d 100644 --- a/pkg/icingadb/ha.go +++ b/pkg/icingadb/ha.go @@ -390,7 +390,7 @@ func (h *HA) realize( OnRetryableError: func(_ time.Duration, attempt uint64, err, lastErr error) { if lastErr == nil || err.Error() != lastErr.Error() { log := h.logger.Debugw - if attempt > 2 { + if attempt > 3 { log = h.logger.Infow } @@ -398,10 +398,10 @@ func (h *HA) realize( } }, OnSuccess: func(elapsed time.Duration, attempt uint64, lastErr error) { - if attempt > 0 { + if attempt > 1 { log := h.logger.Debugw - if attempt > 3 { + if attempt > 4 { // We log errors with severity info starting from the fourth attempt, (see above) // so we need to log success with severity info from the fifth attempt. log = h.logger.Infow @@ -409,7 +409,7 @@ func (h *HA) realize( log("Instance updated/inserted successfully after error", zap.Duration("after", elapsed), - zap.Uint64("attempts", attempt+1), + zap.Uint64("attempts", attempt), zap.NamedError("recovered_error", lastErr)) } }, diff --git a/pkg/retry/retry.go b/pkg/retry/retry.go index fb3b20b9..171fcc87 100644 --- a/pkg/retry/retry.go +++ b/pkg/retry/retry.go @@ -50,7 +50,7 @@ func WithBackoff( } start := time.Now() - for attempt := uint64(0); ; /* true */ attempt++ { + for attempt := uint64(1); ; /* true */ attempt++ { prevErr := err if err = retryableFunc(ctx); err == nil {