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

NPE in RecordAccumulator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 1.0.0
    • 1.0.0
    • None
    • None

    Description

      I found this inadvertently while trying to create a system test to reproduce KAFKA-6003

      java.lang.NullPointerException
              at org.apache.kafka.clients.producer.internals.RecordAccumulator.drain(RecordAccumulator.java:542)
              at org.apache.kafka.clients.producer.internals.Sender.sendProducerData(Sender.java:270)
              at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:238)
              at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:163)
              at java.lang.Thread.run(Thread.java:748)
      

      The problem is with this line

      if (first.hasSequence() && first.baseSequence() != transactionManager.nextBatchBySequence(first.topicPartition).baseSequence())
      

      It is possible for the producer state to be reset (for instance if retries are expired), in which case the transaction manager will drop the in flight batches it is tracking. However, these batches will continue to be in the accumulator with a sequence, causing an NPE in the background thread on this line.

      It would be better to drain the batches with the old Pid/Sequence in this case. Either they are accepted, or they will be returned to the user with an OutOfOrderSequenceException which is clearer.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: