dataengref errors

Home / Kafka / Producer

Kafka producer: TimeoutException: Expiring N record(s) for topic-partition

org.apache.kafka.common.errors.TimeoutExceptionExpiring 12 record(s) for orders-3:120001 ms has passed since batch creation. The request has not been sent, or no server response has been received yet.

Records waited in the producer longer than delivery.timeout.ms (120 seconds by default) without being acknowledged, so the producer failed them. The producer could not reach the partition leader fast enough, or the broker did not answer.

Causes · Fixes · Source

Common causes

  1. The partition leader is unavailable or moving, so batches cannot be sent.How to confirm: Broker logs or kafka-topics --describe show the partition without a leader or with leadership changes at that time.
  2. The producer is sending faster than the brokers or network can accept, so batches queue up.How to confirm: Producer metrics show record-queue-time-avg close to the timeout and buffer-available-bytes near zero.
  3. Network or authentication problems between the client and the brokers.How to confirm: The client log shows repeated disconnects or authentication failures before the expiry.

How to fix it

Fix broker availability or network issues first; raising timeouts only delays the failure.

Give batches more time when brokers are healthy but slow, keeping delivery.timeout.ms at least linger.ms + request.timeout.ms.

SettingDefaultNote
delivery.timeout.ms120000
request.timeout.ms30000
linger.ms5

Reduce load per producer: more partitions, compression, or larger batches.

SettingDefaultNote
batch.size16384
compression.typenone

Where the message comes from

Message template in the source: Expiring %d record(s) for %s:%d ms has passed since batch creation. The request has not been sent, or no server response has been received yet.

References

Related errors

Last checked: