Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-4815 Idempotent/transactional Producer (KIP-98)
  3. KAFKA-5364

Producer attempts to send transactional messages before adding partitions to transaction

    XMLWordPrintableJSON

Details

    Description

      Due to a race condition between the sender thread and the producer.send(), the following is possible:

      1. In KakfaProducer.doSend(), we add partitions to the transaction and then do accumulator.append.
      2. In Sender.run(), we check whether there are transactional request. If there are, we send them and wait for the response.
      3. If there aren't we drain the accumulator queue and send the produce requests.
      4. The problem is that the sequence step 2, 1, 3 is entire possible. This means that we won't send the 'AddPartitions' request but yet try to send the produce data. Which results in a fatal error and requires the producer to close.

      The solution is that in the accumulator.drain, we should check again if there are pending add partitions requests, and if so, don't drain anything.

      Attachments

        1. KAFKA-5364.tar.gz
          5.18 MB
          Apurva Mehta

        Activity

          People

            apurva Apurva Mehta
            apurva Apurva Mehta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: