Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-14303

Producer.send without record key and batch.size=0 goes into infinite loop

    XMLWordPrintableJSON

Details

    Description

      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:

      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)
        }
      } 

       

      Documentation for producer configuration states batch.size=0 as a valid value:

      Valid Values: [0,...]

      and recommends its use directly:

      A small batch size will make batching less common and may reduce throughput (a batch size of zero will disable batching entirely).

      Attachments

        Issue Links

          Activity

            People

              soarez Igor Soarez
              soarez Igor Soarez
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: