Skip to content

Commit

Permalink
fix(inputs.kafka_consumer): Fix deadlock (#16074)
Browse files Browse the repository at this point in the history
  • Loading branch information
zak-pawel authored Oct 24, 2024
1 parent f061114 commit 662607c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions plugins/inputs/kafka_consumer/kafka_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type KafkaConsumer struct {
topicClient sarama.Client
regexps []regexp.Regexp
allWantedTopics []string
ticker *time.Ticker
fingerprint string

parser telegraf.Parser
Expand Down Expand Up @@ -376,15 +375,13 @@ func (k *KafkaConsumer) Gather(_ telegraf.Accumulator) error {
}

func (k *KafkaConsumer) Stop() {
if k.ticker != nil {
k.ticker.Stop()
}
// Lock so that a topic refresh cannot start while we are stopping.
k.topicLock.Lock()
defer k.topicLock.Unlock()
if k.topicClient != nil {
k.topicClient.Close()
}
k.topicLock.Unlock()

k.cancel()
k.wg.Wait()
}
Expand Down

0 comments on commit 662607c

Please sign in to comment.