IBM / sarama

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

Should share the max retries of metadata? #2895

Open yitian108 opened 1 month ago

yitian108 commented 1 month ago

Description

When reviewing the function tryRefreshMetadata() in client.go, I noticed a shared variable attemptsRemaining (initialized as Metadata.Retry.Max) within the subfunction retry(). Every call to the function retry() decreases the value of attemptsRemaining. For instance, if the initial value of attemptsRemaining is 3, when the broker is unavailable, it decreases by 1. In another scenario where there is no leader for some partitions, attemptsRemaining decreases from 2 instead of the initial value of 3. Shouldn't it be reset for different reasons?

The snippet of the func tryRefreshMetadata()

image

Sarama version: 1.42.2

puellanivis commented 1 month ago

I’ve not really heard of a situation where attempts are per specific error issue, rather than just generically for any issue.