Closed sykesm closed 5 years ago
The implementation of Stop is using a lock instead of atomic.CompareAndSwapUint32 to serialize the stopped flag. This races with the implementation of Mark that uses atomic.LoadUint32 as there is no serialization guarantee between the two.
Stop
atomic.CompareAndSwapUint32
stopped
Mark
atomic.LoadUint32
WARNING: DATA RACE Write at 0x00c420312478 by goroutine 126: github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardMeter).Stop() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/meter.go:151 +0x6f github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardRegistry).stop() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/registry.go:227 +0xe4 github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardRegistry).Unregister() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/registry.go:189 +0x8f github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).Close() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:186 +0x6cc github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.safeAsyncClose.func1() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/utils.go:52 +0x70 github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.withRecover() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/utils.go:45 +0x50 Previous read at 0x00c420312478 by goroutine 111: sync/atomic.LoadInt32() /opt/go/src/runtime/race_amd64.s:206 +0xb github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics.(*StandardMeter).Mark() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/rcrowley/go-metrics/meter.go:167 +0x42 github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).updateOutgoingCommunicationMetrics() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:878 +0x1db github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).send() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:582 +0x50c github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).sendAndReceive() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:601 +0x80 github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*Broker).Produce() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/broker.go:267 +0x138 github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.(*asyncProducer).newBrokerProducer.func1() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/async_producer.go:572 +0xe1 github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama.withRecover() /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/Shopify/sarama/utils.go:45 +0x50
Ping. Just ran into this issue too.
The implementation of
Stop
is using a lock instead ofatomic.CompareAndSwapUint32
to serialize thestopped
flag. This races with the implementation ofMark
that usesatomic.LoadUint32
as there is no serialization guarantee between the two.