diff --git a/consumer_group.go b/consumer_group.go index 80f625d80..2bf236ae5 100644 --- a/consumer_group.go +++ b/consumer_group.go @@ -732,6 +732,9 @@ func (s *consumerGroupSession) heartbeatLoop() { pause := time.NewTicker(s.parent.config.Consumer.Group.Heartbeat.Interval) defer pause.Stop() + retryBackoff := time.NewTimer(s.parent.config.Metadata.Retry.Backoff) + defer retryBackoff.Stop() + retries := s.parent.config.Metadata.Retry.Max for { coordinator, err := s.parent.client.Coordinator(s.parent.groupID) @@ -740,11 +743,11 @@ func (s *consumerGroupSession) heartbeatLoop() { s.parent.handleError(err, "", -1) return } - + retryBackoff.Reset(s.parent.config.Metadata.Retry.Backoff) select { case <-s.hbDying: return - case <-time.After(s.parent.config.Metadata.Retry.Backoff): + case <-retryBackoff.C: retries-- } continue