IBM / sarama

Sarama is a Go library for Apache Kafka.
MIT License
11.57k stars 1.76k forks source link

Concurrent RefreshMetadata can incorrectly return nil #2518

Closed hindessm closed 1 year ago

hindessm commented 1 year ago
Versions
Sarama Kafka Go
6ecdb50 saramaMock 1.20.6
Problem Description

I get occasional failures running:

go test -run TestClientUpdateMetadataErrorAndRetry -count 1000

I believe the issue is due to changes in #2256. It is possible to hit the return nil here and have the concurrent RefreshMetadata that caused the code to reach this line fail. In fact, even if you close the seedBroker (so the refresh must fail) the call can return nil due to this logic/race issue.

hindessm commented 1 year ago

I just noticed #2438 already mentions this issue as a possible cause.