Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-25106

A new Kafka consumer gets created for every batch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.3.1
    • None
    • Structured Streaming
    • None

    Description

      I have a fairly simple piece of code that reads from Kafka, applies some transformations - including applying a UDF - and writes the result to the console. Every time a batch is created, a new consumer is created (and not closed), eventually leading to a "too many open files" error.

      I created a test case, with the code available here: https://github.com/aseigneurin/spark-kafka-issue

      To reproduce:

      1. Start Kafka and create a topic called "persons"
      2. Run "Producer" to generate data
      3. Run "Consumer"

      I am attaching the log where you can see a new consumer being initialized between every batch.

      Please note this issue does not appear with Spark 2.2.2, and it does not appear either when I don't apply the UDF.

      I am suspecting - although I did go far enough to confirm - that this issue is related to the improvement made in SPARK-23623.

      Attachments

        1. console.txt
          61 kB
          Alexis Seigneurin

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aseigneurin Alexis Seigneurin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: