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

Divide by zero in DefaultPartitioner

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      The following exception was observed in a Kafka Streams application running on Kafka 2.3:

      java.lang.ArithmeticException: / by zero
      at org.apache.kafka.clients.producer.internals.DefaultPartitioner.partition(DefaultPartitioner.java:69)
      at org.apache.kafka.streams.processor.internals.DefaultStreamPartitioner.partition(DefaultStreamPartitioner.java:39)
      at org.apache.kafka.streams.processor.internals.StreamsMetadataState.getStreamsMetadataForKey(StreamsMetadataState.java:255)
      at org.apache.kafka.streams.processor.internals.StreamsMetadataState.getMetadataWithKey(StreamsMetadataState.java:155)
      at org.apache.kafka.streams.KafkaStreams.metadataForKey(KafkaStreams.java:1019)

      The cause is that the Cluster returns an empty list from partitionsForTopic(topic) and the size is then used as a divisor.

      The same pattern of using the size of the partitions as divisor is used in other implementations of Partitioner and also StickyPartitionCache, so presumably they're also prone to this problem when Cluster lacks information about a topic.

      Attachments

        Issue Links

          Activity

            People

              tombentley Tom Bentley
              tombentley Tom Bentley
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: