-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Description
We are encountering an error (once every few weeks) while using the async producer in our Kafka setup. The error message encountered is as follows:
assertion failed: message out of sequence added to a batch
This error seems to originate from the following line in the Sarama library:
produce_set.go#L89
The occurrence of this error is sporadic, and we are struggling to understand the underlying cause or identify any corrective measures. It appears that, occasionally, messages are being added to the batch in an incorrect order.
We are seeking insights or suggestions on what might be triggering this error. Our investigations have considered network issues as a potential cause; however, we have not found any corresponding logs or indicators to substantiate this theory when the error occurs.
Versions
| Sarama | Kafka | Go |
|---|---|---|
| v1.42.1 | 2.6.2 | 1.20.6 |
Configuration
config := sarama.NewConfig()
config.Version = version
config.Consumer.Group.Rebalance.Strategy = sarama.NewBalanceStrategySticky()
config.Producer.RequiredAcks = sarama.WaitForAll
config.Producer.Idempotent = true
config.Net.MaxOpenRequests = 1
config.Producer.Retry.Max = 100000
config.Producer.Retry.Backoff = 100 * time.Millisecond
config.Producer.Return.Successes = true
config.Producer.Return.Errors = true
config.Producer.Partitioner = sarama.NewHashPartitionerLogs
We are facing the error detailed at the following location:
produce_set.go#L89
Additional Context
All messages are dispatched using an asynchronous producer, configured with a high retry count to ensure message delivery even in the event of transient Kafka broker failures. Despite this, we observe that occasionally a message fails to be added to the batch, rendering it ineligible for any retry mechanism in Sarama.