kafka-go icon indicating copy to clipboard operation
kafka-go copied to clipboard

Should retry when the error occurs.kafka.(*Client).Produce: fetch request error: topic partition has no leader

Open stonever opened this issue 1 year ago • 2 comments

Describe the bug

Kafka is encountering this error for some reason, but the client should support retries. I have configured the number of retries, but it is not working.

My code:

w := &kafka.Writer{
		Addr:                   kafka.TCP(option.Broker...),
		Topic:                  topic,
		Balancer:               &kafka.Hash{},
		Async:                  true,
		RequiredAcks:           kafka.RequireAll,
		Transport:              transport,
		MaxAttempts:            100,
		AllowAutoTopicCreation: true,
		Logger: kafka.LoggerFunc(func(s string, i ...interface{}) {
			log.With(ctx).Info().Msgf(s, i...)
		}),
		ErrorLogger: kafka.LoggerFunc(func(s string, i ...interface{}) {
			log.With(ctx).Error().Msgf(s, i...)
		}),
	}

stonever avatar May 09 '24 03:05 stonever

I also meet this question . I'm not familiar with kafka .... Why this question happen ? Kafka config error or others ?

Modestying avatar Jan 22 '25 03:01 Modestying

Kafka throw this error, and it is not retryable. Attaching the error which is returned in this case Image

If you see the error is of type protocol.TopicPartitionError which is produce.Error and the library did not retry for this type of error.

The library only try for https://github.com/segmentio/kafka-go/blob/0cbe406d4f176d0d55eb8bd0997c2bba20fe4b9e/error.go#L138C16-L138C25 and Network error

Library should handle this error too.

nimesh-zepto avatar Apr 25 '25 08:04 nimesh-zepto

Is there any updates on this? I meet the same problem.

wyzzzl avatar Aug 21 '25 02:08 wyzzzl