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

A new Kafka consumer gets created for every batch

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.3.1
    • Fix Version/s: None
    • Component/s: Structured Streaming
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: