Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock in consumer group handleError #1581

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions consumer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ func (c *consumerGroup) Close() (err error) {
c.closeOnce.Do(func() {
close(c.closed)

c.lock.Lock()
defer c.lock.Unlock()

// leave group
if e := c.leave(); e != nil {
err = e
Expand Down Expand Up @@ -384,8 +381,10 @@ func (c *consumerGroup) balance(members map[string]ConsumerGroupMemberMetadata)
return strategy.Plan(members, topics)
}

// Leaves the cluster, called by Close, protected by lock.
// Leaves the cluster, called by Close.
func (c *consumerGroup) leave() error {
c.lock.Lock()
defer c.lock.Unlock()
if c.memberID == "" {
return nil
}
Expand Down Expand Up @@ -430,9 +429,6 @@ func (c *consumerGroup) handleError(err error, topic string, partition int32) {
return
}

c.lock.Lock()
defer c.lock.Unlock()

select {
case <-c.closed:
//consumer is closed
Expand Down