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

[kafka-consumer] Use wait group to ensure goroutine is finished before returning from Close #4582

Merged
merged 5 commits into from Jul 14, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions cmd/ingester/app/consumer/consumer.go
Expand Up @@ -75,7 +75,9 @@ func New(params Params) (*Consumer, error) {
// Start begins consuming messages in a go routine
func (c *Consumer) Start() {
c.deadlockDetector.start()
c.doneWg.Add(1)
go func() {
defer c.doneWg.Done()
c.logger.Info("Starting main loop")
for pc := range c.internalConsumer.Partitions() {
c.partitionMapLock.Lock()
Expand Down
1 change: 1 addition & 0 deletions cmd/ingester/app/consumer/consumer_test.go
Expand Up @@ -79,6 +79,7 @@ func newSaramaClusterConsumer(saramaPartitionConsumer sarama.PartitionConsumer,
saramaClusterConsumer.On("Partitions").Return((<-chan cluster.PartitionConsumer)(pcha))
saramaClusterConsumer.On("Close").Return(nil).Run(func(args mock.Arguments) {
mc.Close()
close(pcha)
})
saramaClusterConsumer.On("MarkPartitionOffset", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
return saramaClusterConsumer
Expand Down