[ 
https://issues.apache.org/jira/browse/KAFKA-14303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17617666#comment-17617666
 ] 

Igor Soarez commented on KAFKA-14303:
-------------------------------------

The issue can be more specifically replicated with a unit test on 
{{{}RecordAccumulator{}}}, adding this test to {{RecordAccumulatorTest}}
{code:java}
@Test
public void testBatchSizeZero() throws Exception {
    int batchSize = 0;
    long totalSize = 1024 * 1024;
    RecordAccumulator accum = createTestRecordAccumulator(batchSize, totalSize, 
CompressionType.NONE, 10);
    accum.append(topic, RecordMetadata.UNKNOWN_PARTITION, 0, key, new byte[32], 
Record.EMPTY_HEADERS,
            null, maxBlockTimeMs, false, time.milliseconds(), cluster);
}
{code}

> 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.0, 3.3.1
>            Reporter: Igor Soarez
>            Priority: Major
>              Labels: Partitioner, bug, client, producer, regresion
>
> 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