Hello,

I ran into a potential bug with the Kafka producer. Here is a brief description:

When the broker rejects a batch with MESSAGE_TOO_LARGE, the Sender code will 
call down into ProducerBatch.split(), which reassigns sequences to the pieces
- 
https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/ProducerBatch.java#L422

The issue lies when this batch split straddles 2^31, yielding a negative 
sequence number. This resulted in the producer stalling, and finally a 
BufferExhaustedException.

There is a wrap-safe helper for exactly this, added in 
https://issues.apache.org/jira/browse/KAFKA-7693.
- 
https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/record/internal/DefaultRecordBatch.java#L568

The change that I am proposing would only be a one-liner change to use that 
helper, as opposed to the raw int add.

This is my first exposure to the Kafka codebase, but I am more than happy to 
submit a JIRA ticket and work on a PR.

Best,
Chris Jakins

Reply via email to