Skip to content

Commit

Permalink
Merge pull request #1963 from Shopify/dnwe/fix-leaky-consumergroup
Browse files Browse the repository at this point in the history
fix: ensure backoff timer is re-used
  • Loading branch information
dnwe authored Jun 9, 2021
2 parents fca0631 + 4932617 commit ad66013
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions consumer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit ad66013

Please sign in to comment.