Igor Soarez created KAFKA-14303:
-----------------------------------

             Summary: Producer.send without record key and batch.size=0 goes 
into infinite loop
                 Key: KAFKA-14303
                 URL: https://issues.apache.org/jira/browse/KAFKA-14303
             Project: Kafka
          Issue Type: Bug
          Components: clients, producer 
    Affects Versions: 3.3.1, 3.3.0
            Reporter: Igor Soarez


3.3 has broken previous producer behavior.

A call to {{producer.send(record)}} with a record without a key and configured 
with {{batch.size=0}} never returns.

Reproducer:
{code:java}
class ProducerIssueTest extends IntegrationTestHarness {
  override protected def brokerCount = 1
  @Test
  def testProduceWithBatchSizeZeroAndNoRecordKey(): Unit = {
    val topicName = "foo"
    createTopic(topicName)
    val overrides = new Properties
    overrides.put(ProducerConfig.BATCH_SIZE_CONFIG, 0)
    val producer = createProducer(keySerializer = new StringSerializer, 
valueSerializer = new StringSerializer, overrides)
    val record = new ProducerRecord[String, String](topicName, null, "hello")
    val future = producer.send(record) // goes into infinite loop here
    future.get(10, TimeUnit.SECONDS)
  }
} {code}
 

[Documentation for producer 
configuration|https://kafka.apache.org/documentation/#producerconfigs_batch.size]
 states {{batch.size=0}} as a valid value:
{quote}Valid Values: [0,...]
{quote}
and recommends its use directly:
{quote}A small batch size will make batching less common and may reduce 
throughput (a batch size of zero will disable batching entirely).
{quote}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to