Skip to content

Commit

Permalink
Merge pull request #400 from liftbridge-io/fix_race_condition
Browse files Browse the repository at this point in the history
Fix data race on consumer assignments
  • Loading branch information
tylertreat committed Mar 16, 2022
2 parents 6fe2ebc + 4b74a6e commit 24e1b85
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,14 @@ func (c *consumerGroup) GetAssignments(consumerID string, epoch uint64) (
}
member.timer.Reset(c.consumerTimeout)

return member.assignments, c.epoch, nil
assignments := make(partitionAssignments, len(member.assignments))
for stream, partitions := range member.assignments {
partitionAssignments := make([]int32, len(partitions))
copy(partitionAssignments, partitions)
assignments[stream] = partitionAssignments
}

return assignments, c.epoch, nil
}

// Close should be called when the consumer group is being deleted.
Expand Down

0 comments on commit 24e1b85

Please sign in to comment.