-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Data Race with Incorrect Username or Password #2382
Comments
This comment was marked as outdated.
This comment was marked as outdated.
I can reproduce this in v1.41.2 |
The lines of code identified by the race detector are: Line 248 in 610514e
And Line 1160 in 610514e
So it seems the problem relates to the Broker's I was initially puzzled as to how this could be a race, as the go-routine that reads from the
It then occurred to me that the instance of the Broker struct could be being re-used. So closing the If I hack the broker code to always go down the V1 SASL authentication failure path then the race can be re-produced with a short test-case: func TestRace(t *testing.T) {
b := NewBroker("localhost:9092")
cfg := NewConfig()
_ = b.Open(cfg)
// Block until first open completes
for atomic.LoadInt32(&b.opened) == 1 {
}
_ = b.Open(cfg)
} I suspect the fix is to update the SASL authentication failure path to try and read from the |
Frustratingly, I'm unable to write a testcase that consistently re-produces the issue. If I add a milliseconds sleep just before the call to With the millisecond sleep hacked in to the code, I've been able to confirm that adding a |
The underlying case was not waiting for the goroutine running the `responseReceiver()` method to fully complete if SASL authentication failed. This created a window where a further call to `Broker.Open()` could overwrite the `Broker.done` channel value while the goroutine still running `responseReceiver()` was trying to close the same channel. Fixes: IBM#2382 Signed-off-by: Adrian Preston <[email protected]>
The underlying case was not waiting for the goroutine running the `responseReceiver()` method to fully complete if SASL authentication failed. This created a window where a further call to `Broker.Open()` could overwrite the `Broker.done` channel value while the goroutine still running `responseReceiver()` was trying to close the same channel. Fixes: #2382 Signed-off-by: Adrian Preston <[email protected]>
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.
Configuration
What configuration values are you using for Sarama and Kafka?
Logs
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.0The text was updated successfully, but these errors were encountered: