sarama
sarama copied to clipboard
Data Race with Incorrect Username or Password
I tracked down the root cause to this PR that was merged in 1.34.0 https://github.com/Shopify/sarama/pull/2234/files
Versions
Please specify real version numbers or git SHAs, not just "Latest" since that changes fairly regularly.
| Sarama | Kafka | Go |
|---|---|---|
| v1.37.2 | 2.13-2.7.1 | go version go1.18.2 darwin/amd64 |
Configuration
What configuration values are you using for Sarama and Kafka?
config.Producer.Flush.Bytes = 0
config.Producer.Flush.Frequency = 5 * time.Second
config.Producer.Flush.MaxMessages = 0
config.Producer.Idempotent = true
config.Producer.RequiredAcks = sarama.WaitForAll
config.Producer.Retry.Max = 3
config.Producer.Retry.Backoff = 100 * time.Millisecond
config.Producer.Return.Successes = true
config.Producer.Return.Errors = true
Logs
kafka server: SASL Authentication failed: Authentication failed: Invalid username or password
==================
WARNING: DATA RACE
Write at 0x00c00012e768 by goroutine 74:
github.com/Shopify/sarama.(*Broker).Open.func1()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:248 +0x1a44
github.com/Shopify/sarama.withRecover()
/go/pkg/mod/github.com/!shopify/[email protected]/utils.go:43 +0x48
github.com/Shopify/sarama.(*Broker).Open.func2()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:178 +0x39
Previous read at 0x00c00012e768 by goroutine 72:
github.com/Shopify/sarama.(*Broker).responseReceiver()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:1160 +0x555
github.com/Shopify/sarama.(*Broker).responseReceiver-fm()
<autogenerated>:1 +0x39
github.com/Shopify/sarama.withRecover()
/go/pkg/mod/github.com/!shopify/[email protected]/utils.go:43 +0x48
github.com/Shopify/sarama.(*Broker).Open.func1.2()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:251 +0x39
Goroutine 74 (running) created at:
github.com/Shopify/sarama.(*Broker).Open()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:178 +0x566
github.com/Shopify/sarama.(*client).LeastLoadedBroker()
/go/pkg/mod/github.com/!shopify/[email protected]/client.go:776 +0x1a7
github.com/Shopify/sarama.(*transactionManager).initProducerId.func2()
/go/pkg/mod/github.com/!shopify/[email protected]/transaction_manager.go:514 +0xe5
github.com/Shopify/sarama.(*transactionManager).initProducerId.func1()
/go/pkg/mod/github.com/!shopify/[email protected]/transaction_manager.go:496 +0x139
github.com/Shopify/sarama.(*transactionManager).initProducerId()
/go/pkg/mod/github.com/!shopify/[email protected]/transaction_manager.go:508 +0x7aa
github.com/Shopify/sarama.newTransactionManager()
/go/pkg/mod/github.com/!shopify/[email protected]/transaction_manager.go:872 +0x3cb
github.com/Shopify/sarama.newAsyncProducer()
/go/pkg/mod/github.com/!shopify/[email protected]/async_producer.go:117 +0x92
github.com/Shopify/sarama.NewAsyncProducer()
/go/pkg/mod/github.com/!shopify/[email protected]/async_producer.go:99 +0x84
Goroutine 72 (finished) created at:
github.com/Shopify/sarama.(*Broker).Open.func1()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:251 +0x1c09
github.com/Shopify/sarama.withRecover()
/go/pkg/mod/github.com/!shopify/[email protected]/utils.go:43 +0x48
github.com/Shopify/sarama.(*Broker).Open.func2()
/go/pkg/mod/github.com/!shopify/[email protected]/broker.go:178 +0x39
Problem Description
Our unit tests validate the behaviour of invalid usernames and passwords. It's running into a data race with go test -race. Which was not the case with v1.30.0