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

KafkaProducer is not joining its IO thread properly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.10.2.0
    • Fix Version/s: 0.11.0.3, 1.0.1, 1.1.0
    • Component/s: producer
    • Labels:
      None

      Description

      The KafkaProducer is not properly joining the thread it creates. The code is like this:

      try {
          this.ioThread.join(timeUnit.toMillis(timeout));
      } catch (InterruptedException t) {
          firstException.compareAndSet(null, t);
          log.error("Interrupted while joining ioThread", t);
      }
      

      If the code is interrupted while performing the join, it will end up leaving the io thread running. The correct way of handling this is a follows:

      try {
          this.ioThread.join(timeUnit.toMillis(timeout));
      } catch (InterruptedException t) {
          // propagate the interrupt
          this.ioThread.interrupt();
          try { 
               this.ioThread.join();
          } catch (InterruptedException t) {
              firstException.compareAndSet(null, t);
              log.error("Interrupted while joining ioThread", t);
          } finally {
              // make sure we maintain the interrupted status
              Thread.currentThread.interrupt();
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                huxi_2b huxihx
                Reporter:
                bgedik Bu─čra Gedik
              • Votes:
                2 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: