Skip to content

Data race on broker fetchRate metric #3017

Open
@dejan-lokar

Description

Description

A data race on broker fetchRate metric.

Write:

b.fetchRate = metrics.GetOrRegisterMeter("consumer-fetch-rate", b.metricRegistry)

Read:
if b.fetchRate != nil {

Versions

Sarama v1.43.3

Configuration
Logs
==================
WARNING: DATA RACE
Write at 0x00c0012a00a8 by goroutine 1156:
  github.com/IBM/sarama.(*Broker).Open.func1()
      external/gazelle~~go_deps~com_github_ibm_sarama/broker.go:221 +0xd71
  github.com/IBM/sarama.withRecover()
      external/gazelle~~go_deps~com_github_ibm_sarama/utils.go:43 +0x41
  github.com/IBM/sarama.(*Broker).Open.gowrap1()
      external/gazelle~~go_deps~com_github_ibm_sarama/broker.go:185 +0x33

Previous read at 0x00c0012a00a8 by goroutine 762:
  github.com/IBM/sarama.(*Broker).Fetch.func1()
      external/gazelle~~go_deps~com_github_ibm_sarama/broker.go:501 +0x44
  runtime.deferreturn()
      GOROOT/src/runtime/panic.go:605 +0x5d
  github.com/IBM/sarama.(*brokerConsumer).fetchNewMessages()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer.go:1135 +0x10e4
  github.com/IBM/sarama.(*brokerConsumer).subscriptionConsumer()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer.go:935 +0x144
  github.com/IBM/sarama.(*brokerConsumer).subscriptionConsumer-fm()
      <autogenerated>:1 +0x33
  github.com/IBM/sarama.withRecover()
      external/gazelle~~go_deps~com_github_ibm_sarama/utils.go:43 +0x41
  github.com/IBM/sarama.(*consumer).newBrokerConsumer.gowrap2()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer.go:874 +0x33

Goroutine 1156 (running) created at:
  github.com/IBM/sarama.(*Broker).Open()
      external/gazelle~~go_deps~com_github_ibm_sarama/broker.go:185 +0x571
  github.com/IBM/sarama.(*client).Coordinator()
      external/gazelle~~go_deps~com_github_ibm_sarama/client.go:654 +0xb7
  github.com/IBM/sarama.(*consumerGroupSession).heartbeatLoop()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer_group.go:1011 +0x49b
  github.com/IBM/sarama.newConsumerGroupSession.gowrap1()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer_group.go:838 +0x33

Goroutine 762 (running) created at:
  github.com/IBM/sarama.(*consumer).newBrokerConsumer()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer.go:874 +0x39c
  github.com/IBM/sarama.(*consumer).refBrokerConsumer()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer.go:245 +0x124
  github.com/IBM/sarama.(*consumer).ConsumePartition()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer.go:192 +0x7c7
  github.com/IBM/sarama.newConsumerGroupClaim()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer_group.go:1121 +0xa6
  github.com/IBM/sarama.(*consumerGroupSession).consume()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer_group.go:929 +0x22d
  github.com/IBM/sarama.newConsumerGroupSession.func2()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer_group.go:877 +0x10c
  github.com/IBM/sarama.newConsumerGroupSession.gowrap3()
      external/gazelle~~go_deps~com_github_ibm_sarama/consumer_group.go:878 +0x61
==================

Metadata

Assignees

No one assigned

    Labels

    needs-investigationIssues that require followup from maintainersstale/exemptIssues and pull requests that should never be closed as stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions