Skip to content

Commit

Permalink
fix: off-by-one errors in attempts remaining logging
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Hindess <mark.hindess@gmail.com>
  • Loading branch information
hindessm committed Jul 23, 2023
1 parent 7888004 commit 39c18fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,10 @@ func (client *client) tryRefreshMetadata(topics []string, attemptsRemaining int,
if time.Since(time.Unix(t/1e3, 0)) < backoff {
return err
}
attemptsRemaining--
Logger.Printf("client/metadata retrying after %dms... (%d attempts remaining)\n", backoff/time.Millisecond, attemptsRemaining)

return client.tryRefreshMetadata(topics, attemptsRemaining-1, deadline)
return client.tryRefreshMetadata(topics, attemptsRemaining, deadline)
}
return err
}
Expand Down Expand Up @@ -1160,9 +1161,10 @@ func (client *client) findCoordinator(coordinatorKey string, coordinatorType Coo
retry := func(err error) (*FindCoordinatorResponse, error) {
if attemptsRemaining > 0 {
backoff := client.computeBackoff(attemptsRemaining)
attemptsRemaining--
Logger.Printf("client/coordinator retrying after %dms... (%d attempts remaining)\n", backoff/time.Millisecond, attemptsRemaining)
time.Sleep(backoff)
return client.findCoordinator(coordinatorKey, coordinatorType, attemptsRemaining-1)
return client.findCoordinator(coordinatorKey, coordinatorType, attemptsRemaining)
}
return nil, err
}
Expand Down

0 comments on commit 39c18fc

Please sign in to comment.